[英]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.