如何让 C++ 程序暂停,等待用户输入回车后再继续执行

C语言用getchar();  //需要#include <stdio.h>
或者system("PAUSE");  //需要#include <stdlib.h>
C++语言用cin.get();  //需要#include <iostream>
要说明一点的就是以上几种方法都不是一定要用户输入回车才行,用户输入任意键程序都会继续运行。

例子:

 

#include <iostream>

using namespace std;

int main()
{
    cout << "Hello, World!" << endl;
    //std::cout << "Hello" << std::endl;

    cin.get();
    return 0;
}


posted @ 2010-07-25 17:30  SmartIOI  阅读(11531)  评论(0)    收藏  举报
本站采用CC授权如需转载、引用文章,请务必附上作者及来源处。 Creative Commons License