saeed5884
شنبه 06 خرداد 1391, 16:23 عصر
با سلام
به تازگی شروع به نوشتن این برنامه کردم کردم ولی برنامه کلی مشکل دارد لطفا کمک کنید مشکل این برنامه رو حل کنم اینم کد سورس
// project.cpp : Defines the entry point for the console application.
//
#include<iostream>
#include<stdlib.h>
#include<conio.h>
#include<string>
#include<fstream>
/////////////////////////////////////////////namespace declartion/////////////////////////////////////////
using namespace std;
////////////////////////////////////////////class student////////////////////////////////////////////////
class Student
{
public:
int getid();
char *getname();
char *getfamily();
void setid(int);
void setname(char [20]);
void setfamily(char [20]);
private:
int id;
char name[20];
char family[20];
};////////////////////////////////////////end of class////////////////////////////
void Student::setid(int ID)
{
cin>>ID;
id=ID;
}
void Student::setname(char NAME[20])
{
cin>>NAME[20];
*name=NAME[20];
}
void Student::setfamily(char*FAMILY)
{
cin>>FAMILY[20];
*family=FAMILY[20];
}
int Student::getid()
{
return id;
}
char *Student::getname()
{
return name;
}
char *Student::getfamily()
{
return family;
}
///////////////////////////////////////////////////////////////////////////////
int main()
{//////////////////declaration variable///////////////////////
int Id;
char *Name,*Family,*line;
char ch=0;
Student a;
fstream file;
////////////////////writ to file////////////////////////
file.open("data.txt",ios::out|ios::app);
cout<<"student information store & recover program\n";
cout<<"--------------------------------------------\n";
cout<<"\\ \\\n";
cout<<"\\ created by saeed noruzi \\"<<endl;
cout<<"\\ \\\n";
cout<<"--------------------------------------------\n";
cout<<endl<<"inter id inter name inter family\n";
cout<<"================================================== =====\n";
while(ch!='y')
{
cin>>Id>>Name>>Family;
a.setid(Id);
a.setname(Name);
a.setfamily(Family);
file<<a.getid()<<' '<<a.getname()<<' '<<a.getfamily()<<'.'<<endl;
cout<<"do you want add new record? y|n\n";
}
file.close();
////////////////////////////////////read from file////////////////////////////////
file.open("data.txt",ios::in);
while(! file.eof())
{
file.getline(line,75,'.');
cout<<line<<endl;
}
getch();
return 0;
}
به تازگی شروع به نوشتن این برنامه کردم کردم ولی برنامه کلی مشکل دارد لطفا کمک کنید مشکل این برنامه رو حل کنم اینم کد سورس
// project.cpp : Defines the entry point for the console application.
//
#include<iostream>
#include<stdlib.h>
#include<conio.h>
#include<string>
#include<fstream>
/////////////////////////////////////////////namespace declartion/////////////////////////////////////////
using namespace std;
////////////////////////////////////////////class student////////////////////////////////////////////////
class Student
{
public:
int getid();
char *getname();
char *getfamily();
void setid(int);
void setname(char [20]);
void setfamily(char [20]);
private:
int id;
char name[20];
char family[20];
};////////////////////////////////////////end of class////////////////////////////
void Student::setid(int ID)
{
cin>>ID;
id=ID;
}
void Student::setname(char NAME[20])
{
cin>>NAME[20];
*name=NAME[20];
}
void Student::setfamily(char*FAMILY)
{
cin>>FAMILY[20];
*family=FAMILY[20];
}
int Student::getid()
{
return id;
}
char *Student::getname()
{
return name;
}
char *Student::getfamily()
{
return family;
}
///////////////////////////////////////////////////////////////////////////////
int main()
{//////////////////declaration variable///////////////////////
int Id;
char *Name,*Family,*line;
char ch=0;
Student a;
fstream file;
////////////////////writ to file////////////////////////
file.open("data.txt",ios::out|ios::app);
cout<<"student information store & recover program\n";
cout<<"--------------------------------------------\n";
cout<<"\\ \\\n";
cout<<"\\ created by saeed noruzi \\"<<endl;
cout<<"\\ \\\n";
cout<<"--------------------------------------------\n";
cout<<endl<<"inter id inter name inter family\n";
cout<<"================================================== =====\n";
while(ch!='y')
{
cin>>Id>>Name>>Family;
a.setid(Id);
a.setname(Name);
a.setfamily(Family);
file<<a.getid()<<' '<<a.getname()<<' '<<a.getfamily()<<'.'<<endl;
cout<<"do you want add new record? y|n\n";
}
file.close();
////////////////////////////////////read from file////////////////////////////////
file.open("data.txt",ios::in);
while(! file.eof())
{
file.getline(line,75,'.');
cout<<line<<endl;
}
getch();
return 0;
}