一段c程序,在WIN-TC上可以正常运行,但是把它搬到VC++6.0上就运行不了了..求解..
#include<stdio.h>#include<stdlib.h>voidmain(){FILE*fp;charc;if(!(fp=fopen("TEXT","a")...
#include<stdio.h>
#include<stdlib.h>
void main()
{
FILE*fp;
char c;
if(!(fp=fopen("TEXT","a")))
{printf("can not open the file\n");getch();exit(0);}
c=getchar();
while(c!='!')
{
if(c>='a'&&c<='z')
c-='a'-'A';
putc(c,fp);
c=getchar();
}
fclose(fp);
}
这是那个程序,放到VC++6.0上显示的错误如下:
C:\Documents and Settings\Administrator\桌面\a.c(5) : error C2065: 'FILE' : undeclared identifier
C:\Documents and Settings\Administrator\桌面\a.c(5) : error C2065: 'fp' : undeclared identifier
C:\Documents and Settings\Administrator\桌面\a.c(5) : warning C4552: '*' : operator has no effect; expected operator with side-effect
C:\Documents and Settings\Administrator\桌面\a.c(6) : error C2143: syntax error : missing ';' before 'type'
C:\Documents and Settings\Administrator\桌面\a.c(7) : warning C4013: 'fopen' undefined; assuming extern returning int
C:\Documents and Settings\Administrator\桌面\a.c(8) : warning C4013: 'printf' undefined; assuming extern returning int
C:\Documents and Settings\Administrator\桌面\a.c(8) : warning C4013: 'getch' undefined; assuming extern returning int
C:\Documents and Settings\Administrator\桌面\a.c(9) : error C2065: 'c' : undeclared identifier
C:\Documents and Settings\Administrator\桌面\a.c(9) : warning C4013: 'getchar' undefined; assuming extern returning int
C:\Documents and Settings\Administrator\桌面\a.c(14) : warning C4013: 'putc' undefined; assuming extern returning int
C:\Documents and Settings\Administrator\桌面\a.c(17) : warning C4013: 'fclose' undefined; assuming extern returning int
执行 cl.exe 时出错.
望高人指点,感激不尽~ 展开
#include<stdlib.h>
void main()
{
FILE*fp;
char c;
if(!(fp=fopen("TEXT","a")))
{printf("can not open the file\n");getch();exit(0);}
c=getchar();
while(c!='!')
{
if(c>='a'&&c<='z')
c-='a'-'A';
putc(c,fp);
c=getchar();
}
fclose(fp);
}
这是那个程序,放到VC++6.0上显示的错误如下:
C:\Documents and Settings\Administrator\桌面\a.c(5) : error C2065: 'FILE' : undeclared identifier
C:\Documents and Settings\Administrator\桌面\a.c(5) : error C2065: 'fp' : undeclared identifier
C:\Documents and Settings\Administrator\桌面\a.c(5) : warning C4552: '*' : operator has no effect; expected operator with side-effect
C:\Documents and Settings\Administrator\桌面\a.c(6) : error C2143: syntax error : missing ';' before 'type'
C:\Documents and Settings\Administrator\桌面\a.c(7) : warning C4013: 'fopen' undefined; assuming extern returning int
C:\Documents and Settings\Administrator\桌面\a.c(8) : warning C4013: 'printf' undefined; assuming extern returning int
C:\Documents and Settings\Administrator\桌面\a.c(8) : warning C4013: 'getch' undefined; assuming extern returning int
C:\Documents and Settings\Administrator\桌面\a.c(9) : error C2065: 'c' : undeclared identifier
C:\Documents and Settings\Administrator\桌面\a.c(9) : warning C4013: 'getchar' undefined; assuming extern returning int
C:\Documents and Settings\Administrator\桌面\a.c(14) : warning C4013: 'putc' undefined; assuming extern returning int
C:\Documents and Settings\Administrator\桌面\a.c(17) : warning C4013: 'fclose' undefined; assuming extern returning int
执行 cl.exe 时出错.
望高人指点,感激不尽~ 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询