C++读写输入输出问题

题目描述

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();
}

你期待的结果是什么?实际看到的错误信息又是什么?

阅读 1.2k
1 个回答

这写的好乱啊,head头指针保存数据吗?head传入参数要变为const char…………infile是fstream流对吗?read(unsigned char buf,int num);
t 也打错了

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题