有关Dev-C++的使用问题!!用过的高手进!!

来源:百度知道 编辑:UC知道 时间:2024/06/07 03:18:54
我的程序很简单:
#include<iostream>
using namespace std;

int main()
{
int a;
cout<<"输入:"<<endl;
cin>>a;
cout<<a<<endl;
cout<<"Press the enter to exit";
cin.ignore(cin.rdbuf()->in_avail()+1);
return 0;
}

在Dev-C++中我运行之后,会弹出运行框,但当我在键盘上输入数字之后,敲回车键之后,运行框一闪而过!很快!!按理我已经写了这两行代码:
cout<<"Press the enter to exit";
cin.ignore(cin.rdbuf()->in_avail()+1);
就是防止一闪而过!!我很不明白!希望高手解答!!

dev-c++程序运行完了之后就是会自动退出的,调试的时候你可以加入system("pause")来暂停。

添加getch函数就可以了

#include<iostream>
#include<conio.h>
using namespace std;

int main()
{
int a;
cout<<"输入:"<<endl;
cin>>a;
cout<<a<<endl;
cout<<"Press the enter to exit";
cin.ignore(cin.rdbuf()->in_avail()+1);
getch();
return 0;
}

system("pause");
在结尾加上这个试试