this is my code:
this is my in.txt:Code:#include<iostream> #include<fstream> using namespace std; void readChar(ifstream &inSFile); int main() { ifstream in("in.txt"); readChar(in); } void readChar(ifstream &inSFile) { char ch; do{ while(inSFile.get(ch)) { cout << ch; if(ch=='\n') { break; } } cout << "got a new line"<<endl; } while(ch == '\n' && !inSFile.eof()); }
Output:Code:666666 7777777 88888888
The last line "got a new line" is unexpected, how can I fix it?Code:666666 got a new line 7777777 got a new line 88888888 got a new line got a new line



LinkBack URL
About LinkBacks



