鍍金池/ 問答/C++/ C++讀寫輸入輸出問題

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

你期待的結果是什么?實際看到的錯誤信息又是什么?

回答
編輯回答
枕邊人

這寫的好亂啊,head頭指針保存數據嗎?head傳入參數要變?yōu)閏onst char…………infile是fstream流對嗎?read(unsigned char buf,int num);
t 也打錯了

2017年3月10日 08:59