📄 prog2.cpp
字号:
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
void main()
{
struct student
{
char name[10];
int no;
double score;
} stud[]={"Ma",9902,76,"Li",9906,85.6,"Zheng",9909,
82.5,"Chen",9918,88.6};
fstream file1;
student one;
file1.open("stud.dat",ios::in|ios::out|ios::binary);
for (int i=0;i<4;i++)
file1.write((char*)&stud[i],sizeof(student));
file1.seekp(sizeof(student)*2);
file1.read((char*)&one,sizeof(student));
cout << one.no << " " << one.name << " " << one.score << endl;
file1.close();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -