Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:如果没有输入了,不会停留在cin那一句上吗?

Posted by hong_liming at 2003-07-08 12:35:24 on Problem 1000
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator