如何将一文件的小写字符换成大写字符,并输出在原文件中,不是在文件尾追加!
#include"stdio.h"main()
{
int c;
char filename[80];
FILE *fp;
printf("Please input file path:");
gets(filename);
if((fp=fopen(filename,"r+"))==NULL)
{
printf("file %s can't opened \n",filename);
exit(0);
}
while((c=fgetc(fp))!=EOF)
{
c='a'<=c&&c<='z'?c-'a'+'A':c;
fputc(c,fp);
}
fclose(fp);
}
调试没错,但是输不出预期效果,本意:将磁盘某文件中的字符转换成大写,并在原文件中输出。