c语言错误:'FILE' :illegal use of this type as an expression这是神马情况?#include "stdio.h"#include "string.h"#define K_MAX_PATH 255int main(int argc,char * argv[]){char pszTempPathName[K_MAX_PATH],*p;strcpy(pszTempPathName,argv[0]);p=strr

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/19 21:14:03
c语言错误:'FILE' :illegal use of this type as an expression这是神马情况?#include
xU]OG+S#M- D D5JEm*e^#ٻәY*!%QH $M4Jmժ` 3]uL}S%k=s̙;gZ`6Zmw܅>'5dqL*H\(ÜZlɃϽ܅?NCYeR\9PM%#0T:10:_gKg.GF!P]%F:leP؞2߸*:c:O r ^OFә6Zbdq]XF4t$hvs q"Q E I.\eʦ.\|5P"F*& tL7)6RWKmh.wn˅o.;;;۷DOcY*uz:5!0 Nj8=Iǰ _j&ǒ(lʒbyħ 7-aq1F2(3`$ 5PfVZJh. ’%h>TR⪓IYpQk5BB2K~L^2u\F At&7w]H74Ɨw`|tɦbIqr칋S풲4,Y:Jv V8EhI81J+KNs$""{`u; Q;FQ3㟜W[YwyϽxKj4Nvv}zżFÿ'TӞGȳWWAcN֙m>r}8z]Yk-/7ewY0n>u#+WVwo} {%N [("BX8`U>8"mw ?t-  GGSo8лĩD$X M]H~N88;yIA LfIǁFRB!PS\

c语言错误:'FILE' :illegal use of this type as an expression这是神马情况?#include "stdio.h"#include "string.h"#define K_MAX_PATH 255int main(int argc,char * argv[]){char pszTempPathName[K_MAX_PATH],*p;strcpy(pszTempPathName,argv[0]);p=strr
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
诸位大侠,到底哪里错了?

c语言错误:'FILE' :illegal use of this type as an expression这是神马情况?#include "stdio.h"#include "string.h"#define K_MAX_PATH 255int main(int argc,char * argv[]){char pszTempPathName[K_MAX_PATH],*p;strcpy(pszTempPathName,argv[0]);p=strr
代码没问题
怀疑是纯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);
}