fstream get(char*, int) how to operate empty line?
问题 code in strfile.cpp: #include <fstream> #include <iostream> #include <assert.h> #define SZ 100 using namespace std; int main(){ char buf[SZ]; { ifstream in("strfile.cpp"); assert(in); ofstream out("strfile.out"); assert(out); int i = 1; while(!in.eof()){ if(in.get(buf, SZ)) int a = in.get(); else{ cout << buf << endl; out << i++ << ": " << buf << endl; continue; } cout << buf << endl; out << i++ << ": " << buf << endl; } } return 0; } I want to operate all file but in strfile.out: 1: #include