hi, my app is similar this below:
Qt Code:
  1. fstream file;
  2. while ((choice=getchar()) != '0' ) {
  3. if (!file.open(file_name.c_str(), std::ios_base::in)) { //read only
  4. if ((file()).eof())
  5. cout << "end file \n";
  6. cerr << "unable to open that file\n";
  7. return -1;
  8. }
  9. while ( c=file.get(); ) {
  10. cout.put(ch);
  11. }
  12. f.close();
  13. }
To copy to clipboard, switch view to plain text mode 
I read all file and at the end of first cycle I close the file; but the second cycle, program terminate because file seems to be at the end. Why? I supposed if I close and re-open it goes at begin....thanks