未声明的标识符 - 不确定为什么
问题描述:
我刚学习C未声明的标识符 - 不确定为什么
我写了下面的:
void main(void)
{
unsigned int curr_dat = 0; // The current dat file to use
unsigned char ch = 0; // Key entered at keyboard
unsigned char lastkey = 0; // Last key entered (movement command)
FILE *fp;
}
但是我试图编译时遇到这些错误:error C2065: 'FILE' : undeclared identifier
error C2065: 'fp' : undeclared identifier
warning C4552: '*' : operator has no effect; expected operator with side-effect
我不确定为什么,因为我认为FILE
在C
我使用的开发者命令提示符下VS2012编译
答
FILE
是从stdio.h
类型。要使用它,你必须添加:
#include <stdio.h>
在您的文件的顶部。结果可能是:
#include <stdio.h>
void main(void) {
unsigned int curr_dat = 0; // The current dat file to use
unsigned char ch = 0; // Key entered at keyboard
unsigned char lastkey = 0; // Last key entered (movement command)
FILE *fp;
}
而'int main'而不是'void main' –
谢谢@FredLarson,工作。不知道。 为什么int @AlterMann? – DNKROZ
因为标准所以这样说) –