cout<<"\nroll number of student ";
cin>>start->roll_no;
cout<<"\n\nStudentname of student ";
cin>>start->name;
cout<<"\nmarks in physics out of 100 : ";
cin>>start->p_m;
cout<<"\nmarks in chemistry out of 100 : ";
cin>>start->c_m;
cout<<"\nmarks in maths out of 100 : ";
cin>>start->m_m;
cout<<"\nmarks in english out of 100 : ";
cin>>start->e_m;
cout<<"\nmarks in computer science out of 100 : ";
cin>>start->cs_m;
cout<<"\nroll number of student ";
cin>>start->roll_no;
cout<<"\n\nStudentname of student ";
cin>>start->name;
cout<<"\nmarks in physics out of 100 : ";
cin>>start->p_m;
cout<<"\nmarks in chemistry out of 100 : ";
cin>>start->c_m;
cout<<"\nmarks in maths out of 100 : ";
cin>>start->m_m;
cout<<"\nmarks in english out of 100 : ";
cin>>start->e_m;
cout<<"\nmarks in computer science out of 100 : ";
cin>>start->cs_m;
temp->nxt=NULL;
cur->nxt=temp;
}
calculate();
}
void student::showdata()
{
for(cur=start; cur!=NULL; cur=cur->nxt)
cout<<"\nRoll number of student : "<<cur->roll_no;
cout<<"\nStudentname of student : "<<cur->name;
cout<<"\nMarks in Physics : "<<cur->p_m;
cout<<"\nMarks in Chemistry : "<<cur->c_m;
cout<<"\nMarks in Maths : "<<cur->m_m;
cout<<"\nMarks in English : "<<cur->e_m;
cout<<"\nMarks in Computer Science :"<<cur->cs_m;
cout<<"\nPercentage of student is :"<<cur->per;
cout<<"\nGrade of student is :"<<cur->grade;
}
void display_sp(int n)
{
student st;
ifstream inFile;
inFile.open("student.txt",ios::binary);
if(!inFile)
{
cout<<"File could not be open !! Press any Key...";
getch();
return;
}
int flag=0;
while(inFile.read((char *) &st, sizeof(student)))
{
cur=start;
/*
void modify_student(int n)
{
int found=0;
student st;
fstream File;
File.open("student.txt");
if(!File)
{
cout<<"File could not be open !! Press any Key...";
getch();
return;
}
while(File.read((char *) &st, sizeof(student)) && found==0)
{
if(st.retrollnumber()==n)
{
st.showdata();
cout<<"\n\nPlease Enter The New Details of student"<<endl;
st.getdata();
int pos=(-1)*sizeof(st);
File.seekp(pos,ios::cur);
File.write((char *) &st, sizeof(student));
cout<<"\n\n\t Record Updated";
found=1;
}
}
File.close();
if(found==0)
cout<<"\n\n Record Not Found ";
getch();
}
*/
void delete_student(int n)
{
student st;
ifstream inFile;
inFile.open("student.txt",ios::binary);
if(!inFile)
{
cout<<"File could not be open !! Press any Key...";
getch();
return;
}
ofstream outFile;
outFile.open("Temp.txt",ios::out);
inFile.seekg(0,ios::beg);
cur=start;
while(inFile.read((char *) &st, sizeof(student)))
{
if(cur->
retrollnumber()!=n)
{
outFile.write((char *) &st, sizeof(student));
}
}
outFile.close();
inFile.close();
remove("student.txt");
cout<<"\n\n\tRecord Deleted ..";
getch();
}
void class_result()
{
student st;
ifstream inFile;
inFile.open("student.txt",ios::binary);
if(!inFile)
{
cout<<"File could not be open !! Press any Key...";
getch();
return;
}
cout<<"\n\n\t\tALL STUDENTS RESULT \n\n";
cout<<"==========================================================\n";
cout<<"R.No Studentname P C M E CS %age Grade"<<endl;
cout<<"==========================================================\n";
char ch;
int rno;
cout<<"\n\n\n\tRESULT MENU";
cout<<"\n\n\n\t1. Class Result";
cout<<"\n\n\t2. Student Report Card";
cout<<"\n\n\t3. Back to Main Menu";
cout<<"\n\n\n\tEnter Choice (1/2/3)? ";
cin>>ch;
switch(ch)
{
case '1' :class_result(); break;
case '2' :cout<<"\n\n\tEnter Roll Number Of Student : ";
cin>>rno;
display_sp(rno); break;
case '3' :break;
default :cout<<"\a";
}
}
void intro()
{
cout<<"\n\n\t\tSTUDENT REPORT CARD SYSTEM ";
getch();
}
void entry_menu()
{
int num;
char ch;
cout<<"\n\n\n\tENTRY MENU";
cout<<"\n\n\t1.ADD STUDENT RECORD";
cout<<"\n\n\t2.DISPLAY ALL STUDENTS RECORDS";
cout<<"\n\n\t3.SEARCH STUDENT RECORD ";
cout<<"\n\n\t4.EDIT STUDENT RECORD";
cout<<"\n\n\t5.DELETE STUDENT RECORD";
cout<<"\n\n\t6.BACK TO MAIN MENU";
cout<<"\n\n\tPlease Enter Your Choice (1-6) ";
cin>>ch;
switch(ch)
{
case '1': write_student(); break;
case '2': display_all(); break;
case '3': cout<<"\n\n\tPlease roll number "; cin>>num;
display_sp(num); break;
/* case '4': cout<<"\n\n\tPlease roll number "; cin>>chose->num;
modify_student(chose->num);break;*/
case '5': cout<<"\n\n\tPlease roll number "; cin>>num;
delete_student(num);break;
case '6': break;
default: cout<<"\a"; entry_menu();
}
}
Hello Jun77. Before I help you with your problem, can I ask that you use the code bb-codes on your code so that it is easier to understand. Also, can you tell us the EXACT errors you have been having? Thanks, Spike :D
second, i am calling a function through linklist
like:
"cur->showdata() "
. my data is store in showdata() but it is not working.
ERROR ' struct node' has no member named showdata().
-------------
void display_all()
{
node rec;
ifstream inFile;
inFile.open("student.txt",ios::binary);
if(!inFile)
{
cout<<"File could not be open !! Press any Key...";
getch();
return;
}
cout<<"\n\n\n\t\tDISPLAY ALL RECORD !!!\n\n";
while(inFile.read((char *) &rec, sizeof(rec)))
{
cur=start;
while(cur->nxt!=NULL)
{
cur->showdata() ; // not working
cur=cur->nxt;
}