📄 p11_12.cpp
字号:
/****************************************************
* 程序名:p11_12.cpp *
* 功能: 二进制文件的输入 *
* By Antony *
* 02-08-2005 *
****************************************************/
# include <fstream>
# include <iostream>
using namespace std;
void main() {
char name[8];
float score;
ifstream binfile; //建立输入文件流对象
binfile.open("d:\\c++book\\record.dat",ios::binary);
if(!binfile) {
cerr<<" record.dat open error!"<<endl;
exit(1);
}
while(!binfile.eof()) {
binfile.read(reinterpret_cast<char *>(name),8*sizeof(char));
binfile.read(reinterpret_cast<char *>(&score),sizeof(float));
cout<<name<<'\t'<<score<<endl;
}
binfile.close();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -