为什么getch()在Visual Studio 2008中不起作用?

Lyr*_*yrk 2 c getch visual-studio-2008

下面的代码适用于DevC++,MinGW可以完美地工作,但Visual Studio 2008吐出这个:

error C3861: 'getch': identifier not found . 
Run Code Online (Sandbox Code Playgroud)

如果不可能接受getch(),我可以做些什么来替换getch(),我可以使用它来暂停屏幕?

码:

#include <stdio.h>
#include <conio.h>

int main(void){

    char str[] = "This is the end";
    printf("%s\n", str);
    getch();   //I tried getchar() also still does not work
    return 0;

}
Run Code Online (Sandbox Code Playgroud)

BLU*_*IXY 6

使用_getch()

例如

#define getch() _getch()
Run Code Online (Sandbox Code Playgroud)

样品

#include <stdio.h>
#include <conio.h>

#ifdef _MSC_VER
#define getch() _getch()
#endif

int main(void){

    char str[] = "This is the end";
    printf("%s\n", str);
    getch();
    return 0;

}
Run Code Online (Sandbox Code Playgroud)