struct student
{
int identity;
char name[MAX];
int no_assessment;
char assessmenttask[MAX];
int mark;
};
void appendbfile(char filename [MAX])
{
ofstream writeb;
char filenameb [MAX];
strcpy(filenameb,filename);
student s;
strcat(filenameb,".dat");
cout<<"--------------------------------"
<<endl
<<"Begin appending for binary file "
<<filenameb
<<endl
<<endl;
cout<<"Enter student id: ";
cin>>s.identity;
cout<<"Enter student name: ";
cin>>s.name;
writeb.open(strcpy(filenameb,".dat"),ios::binary);
writeb.seekp(0,ios::end);
writeb.write (reinterpret_cast <const char *>(&s), sizeof (s));
writeb.close();
}
我可以运行该程序,但我似乎无法将记录附加到二进制文件中。谁能帮我看看。
谢谢