题目描述
C++读写问题
题目来源及自己的思路
不知道怎么用链表通过read()函数怎么调用,其中head是头指针
相关代码
// 请把代码文本粘贴到下方(请勿用图片代替代码)
infile.open("student.txt",ios::in);
infile.read((char *)head,sizeof(student)); while(infile)
{
cout<<head->num<<"t"; cout<<head->name<<"t"; cout<<head->score<<endl; head=head->next; infile.read((char *)head,sizeof(student)); }
infile.close();
}
这写的好乱啊,head头指针保存数据吗?head传入参数要变为const char…………infile是fstream流对吗?read(unsigned char buf,int num);
t 也打错了