




世界上总共有 10 种人,一种懂得什么是二进制 ,一种不懂。
但是可以减少操作次数,呵呵~循环减少很多哦!
我知道,我是想知道EOF的效果,为什么会那样?
//try this
#include<iostream>
#include<fstream>
using namespace std;
struct stu{
int num;
int chi;
int math;
int eng;
int phy;
int che;
};
void main(){
const int arraysize=800;//the max lines you read every page
stu s[arraysize];
int i=0;
ifstream in("in.txt");
ofstream out("out.txt");
if(!in||!out){
cerr<<"err"<<endl;
return;
}
while(!in.eof()&&i<arraysize){
in>>s[i].num>>s[i].chi>>s[i].math>>s[i].eng>>s[i].phy>>s[i].che;
i++;
if(i>=arraysize){
cout<<"bufer full"<<endl;
return;
}
}
for(int j=0;j<i-1;j++){
out<<s[j].num<<" "<<
s[j].chi<<" "<<
s[j].math<<" "<<
s[j].eng<<" "<<
s[j].phy<<" "<<
s[j].che<<endl;
}
}