[英]Why getch() is not working in Visual Studio 2008?
下面的代碼可以在DevC ++中與MinGW完美配合,但是Visual Studio 2008會這樣:
error C3861: 'getch': identifier not found .
如果無法做到這一點,我該怎么辦才能接受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;
}
使用_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;
}
您可以使用以及
#include<iostream>
int main()
{
system("pause");
return 0;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.