dev-c++编译后一闪而过。
迷茫
迷茫 2017-04-17 11:39:37
0
3
588

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;
} 
迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(3)
Peter_Zhu

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

  1. First fflush(stdin) (refresh the input buffer), then getchar()
  2. Twicegetchar(), the first time will swallow the previous 回车, and the second time will block the program execution, waiting for input
Ty80
#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;
} 
左手右手慢动作

Add the last line system("pause"); to include the header file #include <stdlib.h>

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!