C语言scanf和printf的使用问题

#include<stdio.h>
void main()
{
int a,b;
printf("please enter four integer \n");
scanf("%d,%d ",&a,&b);
printf("%d,%d",a,b);
getch();
}
运行时出现很奇怪的数字,很郁闷

#include<stdio.h>
void main()
{
int a,b;
printf("please enter four integer \n");
scanf("%d,%d ",&a,&b);//""里面存在空格,要删去,同时输入时,两数字要用逗号隔开
printf("%d,%d",a,b);
getch();
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2008-10-27
scanf语句scanf("%d,%d ",&a,&b);里面的%d之间不能用 , 号隔开
具体如下:
#include<stdio.h>
void main()
{
int a,b;
printf("please enter four integer \n");
scanf("%d%d",&a,&b);
printf("%d\n,%d\n",a,b);
}
输入AB数据时中间用空格,如果想输出字符请用%C
第2个回答  2008-10-27
scanf函数中定义%d%d之间不需要加逗号
相似回答