infile.getline()为什么会导致infile.fail()等于 1 呢??
并且问什么infile.eof() 为什么一直为0
c++ reference :
flag | error |
---|---|
eofbit |
The end of the source of characters is reached during its operations.
|
failbit | No characters were extracted because the end was prematurely found.
|
badbit | An error other than the above happened.
|
当 while(infile.good()换成 while(infile.eof()) 时将是无限死循环。为什么?为什么infile.eof() 总不是 1
infile.getline() infile.get() 出现的问题,还没有解决.换成 getline(infile,str) 就正常了。
所以用高级类型更安全,以后应该用高级类型——string等。