Saturday, November 21, 2009

study notes for fstream

print a file backward


int main(){
Student S;
fin.seekg(0); //back to the first
int i=1;
while(!fin.fail()){
fin.seekg(sizeof(Student*(-1)), ios::end);
if(!fin.fail()){
fin.read((char*)&S, sizeof(Student));
cout << s << endl;
i++;
}
}
}

No comments:

Post a Comment