C++按任意键继续

1.直接调用系统函数 system("pause");
例如:
#include<iostream>
using namespace std;
int main()
{
   system("pause");
   return 0;
}
2.调用getch()函数:需要include<conio.h>
例如:
#include<conio.h>
int main()
{
   prinf("按任意键继续\n");
    getch();
    return 0;
}
3.调用getchar()函数:需要include<stdio.h>
例如:
#include<stdio.h>
int main()
{
   prinf("按 Enter 键继续\n");
   getchar();
   return 0;
}
4.使用cin的get()函数
例如:
#include<iostream>
using namespace std;
int main()
{
  cout<<"按 Enter 键继续"<<endl;
   cin.get();
   return 0;
}
注意:只有前两种可以真正实现“按任意键继续”,后两种必需按下Enter键才行。

posted on 2015-08-16 09:32  zhangyz017  阅读(3355)  评论(0编辑  收藏  举报

导航