scanf()函数有返回值,它返回的是成功输入的变量个数,如:
#include <iostream>
using namespace std;
int main()
{
int a,b;
while(scanf("%d%d",&a,&b)==2)printf("%d\n",a+b);
return 0;
}
本文详细介绍了C语言中scanf函数的使用方法及其返回值的意义。通过一个简单的示例程序展示了如何利用scanf函数读取用户输入的数据,并解释了其返回值代表成功读取的变量数量。
scanf()函数有返回值,它返回的是成功输入的变量个数,如:
#include <iostream>
using namespace std;
int main()
{
int a,b;
while(scanf("%d%d",&a,&b)==2)printf("%d\n",a+b);
return 0;
}
10万+
8891
6357
4857
1259

被折叠的 条评论
为什么被折叠?