转载自https://blog.csdn.net/qq_44833767/article/details/92797978
我们一般所使用的 getchar() 函数在读入一个字符时 必须按一下 enter 键,该代码才会继续运行;
但是 getch() 函数读入一个字符时 不用 enter 代码会继续跑;
#include <iostream> #include <conio.h> #include <stdio.h> #include "Person.h" #include <stdlib.h> using namespace std; int main() { int n = 1; while (1) { for (int i = 0; i < n; i++) { cout << '*' ; } //cout << endl; n++; _getch(); system("cls"); //清屏操作 } return 0; }