scanf的返回值
2012-11-18 17:52
197 查看
关于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。
不经意中发现scanf()的返回值问题,自己试验和了解了一下,一些所知与各位分享;
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。
不经意中发现scanf()的返回值问题,自己试验和了解了一下,一些所知与各位分享;
相关文章推荐
- EOF和scanf返回值
- C语言中scanf()和printf()的返回值问题
- scanf的返回值
- scanf返回值问题
- 关于scanf的返回值
- SCANF返回值问题
- scanf() 的返回值
- scanf 返回值
- Scanf函数的返回值
- 利用c语言scanf返回值来控制非数字值时循环结束
- 循环 scanf的返回值应用与运算符
- gcc中scanf的使用及返回值问题
- 由scanf说起之1:scanf函数和回车、空格 及其返回值
- 高手帮帮忙 C中scanf和printf有带返回值的情况吗 有的话怎么用
- c语言scanf返回值
- scanf()返回值(转)
- c语言中 scanf() 和printf()的返回值
- 利用c语言scanf返回值来控制非数字值时循环结束
- scanf(),printf()以及fscanf(),fprintf()的返回值
- 【C语言】scanf返回值问题