sopherwenxin学习笔记

刀锋上的舞者: 我是风中的落叶,看我如何飞翔
posts - 5, comments - 8, trackbacks - 0, articles - 1

关于scanf的返回值

Posted on 2006-01-15 13:10 sopherwenxin 阅读(3218) 评论(0)  编辑 收藏 引用 所属分类: 编程札记
关于scanf的返回值,MSDN里是这样写的:
Both scanf and wscanf return the number of fields successfully converted
and assigned; the return value does not include fields that were read but
not assigned. A return value of 0 indicates that no fields were assigned.
The return value is EOF for an error or if the end-of-file character or the
end-of-string character is nocountered in the first attempt to read a character.
如:
scanf("%d%d", &a, &b);
如果a和b都被成功读入,那么scanf的返回值就是2
如果只有a被成功读入,返回值为1
如果a和b都未被成功读入,返回值为0
如果遇到错误或遇到end of file,返回值为EOF。

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理