1.直接调用系统函数 system(“pause”); 例如: #include 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 using namespace std; int main() { cout<<“按 Enter 键继续”<<endl; cin.get(); return 0; } 注意:只有前两种可以真正实现“按任意键继续”,后两种必需按下Enter 键才行。
清屏函数:system(“cls”);