End of File in C++
问题 I have a n X 2 matrix stored in a text file as it is. I try to read it in C++ nb_try=0; fin>>c_tmp>>gamma_tmp; while (!fin.eof( )) //if not at end of file, continue reading numbers { // store cs_bit.push_back(c_tmp); gammas_bit.push_back(gamma_tmp); nb_try++; // read fin>>c_tmp; assert(!fin.fail( )); // fail at the nb_try=n if(fin.eof( ))break; fin>>gamma_tmp; // get first number from the file (priming the input statement) assert(!fin.fail( )); } The first assert failes, i.e. fin.fail( ) is