I just found a comment in this answer saying that using iostream::eof
in a loop condition is "almost certainly wrong". I generally use something like while(cin>>n)
- which I guess implicitly checks for EOF, why is checking for eof explicitly using iostream::eof
wrong?
How is it different from using scanf("...",...)!=EOF
in C (which I often use with no problems)?
转载于:https://stackoverflow.com/questions/5605125/why-is-iostreameof-inside-a-loop-condition-considered-wrong