2

以下のコードはDevC++で動作し、MinGWは問題なく動作しますが、Visual Studio 2008はこれを吐き出します:

error C3861: 'getch': identifier not found . 

画面を一時停止するために使用できる 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;

}
4

2 に答える 2

6

_getch()を使用

例えば

#define getch() _getch()

サンプル

#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;

}
于 2013-05-06T19:43:54.747 に答える