dev-c++编译后一闪而过。加了system("pause");或者getchar();也一样。。
#include<stdio.h>
main()
{
int a,b,c;
scanf("%d %d",&a,&b);
c=a+b;
printf("%d",c);
system("pause");
return 0;
}
天蓬老师2017-04-17 11:41:37
You need to import system("pause");
to use stdlib.h
. If it still doesn’t work, it is unreasonable and may have something to do with your machine environment
When using scanf
after getchar()
, you need to clear the input buffer first, because when scanf is entered and the carriage return is entered, scanf is triggered to receive the previous data, but the 回车
character is still in the input buffer, getchar()
This character will be obtained directly, so the window cannot be blocked from closing
The solution is
fflush(stdin)
(refresh the input buffer), then getchar()
getchar()
, the first time will swallow the previous 回车
, and the second time will block the program execution, waiting for input PHP中文网2017-04-17 11:41:37
#include<stdio.h>
#include<stdlib.h>
int main()
{
int a,b,c;
scanf("%d %d",&a,&b);
c=a+b;
printf("%d",c);
system("pause");
return 0;
}
ringa_lee2017-04-17 11:41:37
Add the last line system("pause"); to include the header file #include <stdlib.h>