-HowardFirst, you should be following the advice "mlimber" gave to your previouspost:Pass the filenames to the constructors of the stream objects, instead ofcalling open explicitly.Then, pust the input statement in your while condition, not eof(). Usingeof() in your while statement is incorrect, since it does not detect the endof file until _after_ it fails to read. The eof() test should be used_after_ a read fails, to detect if the _reason_ for the read failure was anend-of-file (as opposed to some other unexpected condition).This is undoubtedly the cause of your problem. If there''s a blank line atthe end of your text file (which there often is, because whoever enters thedata usually hits Enter after each line), then the last time through theloop, it tries to read a blank line into an integer, which fails. Since theread failed, the variable a still contains what it did before, which is thevalue 8. So, you output 8.-Howard 想想看,即使最后还没有额外的 行,它也会表现得这样。 ,因为上次成功读取(值8进入a) 仍然没有设置eof标志。该标志仅在 读取失败后才会设置。 -HowardCome to think of it, it will behave this way even if there''s _not_ an extraline at the end, because the last successful read (of the value 8 into a)will still not have set the eof flag. That flag only gets set after afailure to read occurs.-Howard 这篇关于FILESTREAM需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!