Home > Back-end > C using getline (fin, STR) reads the text file object of ifstream fin each line, what kind of writin
C using getline (fin, STR) reads the text file object of ifstream fin each line, what kind of writin
Time:11-22
C + + using getline (fin, STR) reads the text file object of ifstream fin each line, what kind of writing is good, the result right? Ifstream fin (" a.t xt "); String STR.
1, while(! Eof ()) fin.{ Getline (fin, STR); cout} 2, Getline (fin, STR); while(! Eof ()) fin.{ coutGetline (fin, STR); } 3, While (getline (fin, STR)) { cout} Or is there any other way?
CodePudding user response:
Other writing, for example, while true cycle, abnormal or eof will break, etc. But usually use is your list of 3 And you listed 2 May not correct, general need not
CodePudding user response:
2 if the last line not line/enter, if end of file directly, can read less line