c语言错误:'FILE' :illegal use of this type as an expression这是神马情
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/26 16:05:59
c语言错误:'FILE' :illegal use of this type as an expression这是神马情况?
#include "stdio.h"
#include "string.h"
#define K_MAX_PATH 255
int main(int argc,char * argv[])
{
char pszTempPathName[K_MAX_PATH],*p;
strcpy(pszTempPathName,argv[0]);
p=strrchr(pszTempPathName,'\\')+1;
strcpy(p,"LastResu.bin");
FILE * fp=fopen(pszTempPathName,"wb");
//FILE * fp;
//fp=fopen(pszTempPathName,"wb");//这样写也不行
//if(fp==0){printf("Can not open file:LastResu.bin!");return 1;}
//fclose(fp);
}
编译结果:
D:\KCS\source\rst.c(15) :error C2275:'FILE' :illegal use of this type as an expression
c:\program files\microsoft visual studio\vc98\include\stdio.h(156) :see declaration of 'FILE'
D:\KCS\source\rst.c(15) :error C2065:'fp' :undeclared identifier
点击错误行,弹出stdio.h中的这些行,
#ifndef _FILE_DEFINED
struct _iobuf {
char *_ptr;
int _cnt;
char *_base;
int _flag;
int _file;
int _charbuf;
int _bufsiz;
char *_tmpfname;
};
typedef struct _iobuf FILE;
#define _FILE_DEFINED
#endif
诸位大侠,到底哪里错了?
#include "stdio.h"
#include "string.h"
#define K_MAX_PATH 255
int main(int argc,char * argv[])
{
char pszTempPathName[K_MAX_PATH],*p;
strcpy(pszTempPathName,argv[0]);
p=strrchr(pszTempPathName,'\\')+1;
strcpy(p,"LastResu.bin");
FILE * fp=fopen(pszTempPathName,"wb");
//FILE * fp;
//fp=fopen(pszTempPathName,"wb");//这样写也不行
//if(fp==0){printf("Can not open file:LastResu.bin!");return 1;}
//fclose(fp);
}
编译结果:
D:\KCS\source\rst.c(15) :error C2275:'FILE' :illegal use of this type as an expression
c:\program files\microsoft visual studio\vc98\include\stdio.h(156) :see declaration of 'FILE'
D:\KCS\source\rst.c(15) :error C2065:'fp' :undeclared identifier
点击错误行,弹出stdio.h中的这些行,
#ifndef _FILE_DEFINED
struct _iobuf {
char *_ptr;
int _cnt;
char *_base;
int _flag;
int _file;
int _charbuf;
int _bufsiz;
char *_tmpfname;
};
typedef struct _iobuf FILE;
#define _FILE_DEFINED
#endif
诸位大侠,到底哪里错了?
代码没问题
怀疑是纯C环境 比较老的版本
所以要求变量定义只能在开头
你改成这样试试
#include "stdio.h"
#include "string.h"
#define K_MAX_PATH 255
int main(int argc,char * argv[])
{
char pszTempPathName[K_MAX_PATH],*p;
FILE * fp;
strcpy(pszTempPathName,argv[0]);
p=strrchr(pszTempPathName,'\\')+1;
strcpy(p,"LastResu.bin");
fp=fopen(pszTempPathName,"wb");
//FILE * fp;
//fp=fopen(pszTempPathName,"wb");//这样写也不行
//if(fp==0){printf("Can not open file:LastResu.bin!");return 1;}
//fclose(fp);
}
怀疑是纯C环境 比较老的版本
所以要求变量定义只能在开头
你改成这样试试
#include "stdio.h"
#include "string.h"
#define K_MAX_PATH 255
int main(int argc,char * argv[])
{
char pszTempPathName[K_MAX_PATH],*p;
FILE * fp;
strcpy(pszTempPathName,argv[0]);
p=strrchr(pszTempPathName,'\\')+1;
strcpy(p,"LastResu.bin");
fp=fopen(pszTempPathName,"wb");
//FILE * fp;
//fp=fopen(pszTempPathName,"wb");//这样写也不行
//if(fp==0){printf("Can not open file:LastResu.bin!");return 1;}
//fclose(fp);
}
c语言错误:'FILE' :illegal use of this type as an expression这是神马情
illegal use of this type as an expression是什么意思?
illegal use of this type as an expression
error C2275:'STU' :illegal use of this type as an expression
运行后说error C2275:'list' :illegal use of this type as an expre
报错c(179) :error C2275:'LNODE' :illegal use of this type as a
程序为何会显示 illegal use of type 'void'
illegal expression是什么错误?pascal
illegal start of expression是什么意思
Use the properties of logarithms to expand the expression as
英语翻译英文是:checking file system on c:the type of your disks nee
c语言中这是怎麽回事illegal case illegal break