_getch()函数的一些使用方法

转载自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;
}
原文地址:https://www.cnblogs.com/Es-war/p/12829040.html