回复 3楼 pangshch
#include<stdio.h>
#include<string.h>
main()
{
char string[100];
gets(string);
FILE *fp;
if((fp=fopen("text.txt","w"))==NULL)
puts("Error on opening output file text");
int i;
for(i=0;string[i]!='!';i++)
if(string[i]>='a'&&string[i]<='z')
{string[i]=string[i]-32;
fputc(string[i],fp);
i++;
}
fclose(fp);
fp=fopen("test.txt","r");
fgets(string,strlen(string)-1,fp);
printf("%s",string);
fclose(fp);
}
还是不行,并且调试显示的错误很奇怪。
说我i 没定义什么的。。
C:\Users\Administrator\Desktop\yen\新建文件夹\za\9-2.c(7) : error C2275: 'FILE' : illegal use of this type as an expression
c:\program files (x86)\microsoft visual studio\vc98\include\stdio.h(156) : see declaration of 'FILE'
C:\Users\Administrator\Desktop\yen\新建文件夹\za\9-2.c(7) : error C2065: 'fp' : undeclared identifier
C:\Users\Administrator\Desktop\yen\新建文件夹\za\9-2.c(9) : warning C4047: '=' : 'int ' differs in levels of indirection from 'struct _iobuf *'
C:\Users\Administrator\Desktop\yen\新建文件夹\za\9-2.c(9) : warning C4047: '==' : 'int ' differs in levels of indirection from 'void *'
C:\Users\Administrator\Desktop\yen\新建文件夹\za\9-2.c(13) : error C2143: syntax error : missing ';' before 'type'
C:\Users\Administrator\Desktop\yen\新建文件夹\za\9-2.c(14) : error C2065: 'i' : undeclared identifier
C:\Users\Administrator\Desktop\yen\新建文件夹\za\9-2.c(18) : warning C4047: 'function' : 'struct _iobuf *' differs in levels of indirection from 'int '
C:\Users\Administrator\Desktop\yen\新建文件夹\za\9-2.c(18) : warning C4024: 'fputc' : different types for formal and actual parameter 2
C:\Users\Administrator\Desktop\yen\新建文件夹\za\9-2.c(22) : warning C4047: 'function' : 'struct _iobuf *' differs in levels of indirection from 'int '
C:\Users\Administrator\Desktop\yen\新建文件夹\za\9-2.c(22) : warning C4024: 'fclose' : different types for formal and actual parameter 1
C:\Users\Administrator\Desktop\yen\新建文件夹\za\9-2.c(23) : warning C4047: '=' : 'int ' differs in levels of indirection from 'struct _iobuf *'
C:\Users\Administrator\Desktop\yen\新建文件夹\za\9-2.c(24) : warning C4047: 'function' : 'struct _iobuf *' differs in levels of indirection from 'int '
C:\Users\Administrator\Desktop\yen\新建文件夹\za\9-2.c(24) : warning C4024: 'fgets' : different types for formal and actual parameter 3
C:\Users\Administrator\Desktop\yen\新建文件夹\za\9-2.c(26) : warning C4047: 'function' : 'struct _iobuf *' differs in levels of indirection from 'int '
C:\Users\Administrator\Desktop\yen\新建文件夹\za\9-2.c(26) : warning C4024: 'fclose' : different types for formal and actual parameter 1
执行 cl.exe 时出错.