C语言小问题!求助!!

来源:百度知道 编辑:UC知道 时间:2024/05/27 12:14:56
#include "stdio.h"
void main()
{
int a,b,sum;
scanf("%d%d",&a,&b);
sum=a+b;
printf("sum is%d\n",sum);
}
这段中调试没有错误!,但是结果出的不对啊!我运行后应该在屏幕上输入数字的啊!但是我按了一个数字它就自动退出了!请问我错在那里?

最后加一句, getch();
这样你就能看到你的输出了.

最后加system("pause");

程序中没有停顿,输入语句没有被执行!
在scanf("%d%d",&a,&b);
前面加一句
printf("input a,b\n");
即可!
#include "stdio.h"
void main()
{
int a,b,sum;
printf("input a,b\n");
scanf("%d%d",&a,&b);
sum=a+b;
printf("sum is%d\n",sum);
}

#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,sum;
scanf("%d%d",&a,&b);
sum=a+b;
printf("sum is%d\n",sum);

getch();
return 0;
}

这样就可以了 用getch() 停一下 不然 就直接推出了