| ||||||||||
Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:如果没有输入了,不会停留在cin那一句上吗?In Reply To:如果没有输入了,不会停留在cin那一句上吗? Posted by:waterine at 2003-07-07 19:31:06 c++和pascal不太一样,pascal中最后一项数据读完,eof(f)就返回真了,而c++在这时不去判断文件是否读完.最后一项数据读完以后,再读下一项,产生一个错误,(但并不会停留,只是所读变量没有被赋值),这时eof(f)检测到这个错误才意识到文件已经读完了,返回真. 书上是这么写的, if(!cin)等价于if(cin.fail()) if(cin)等价于if(cin.good()) Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator