Type value; while(inFile >> value) { //loop body goes here. } if(inFile.eof()) { //terminated with EOF } else if(inFile.fail()) { //terminated with mismatch } else { //terminated with some reason unknown }
原文:http://www.cnblogs.com/xyqhello/p/3523439.html