c编程急救!!编写程序,从文本文件中读取全部内容,复制到另一文件中,要求将所有英文字母转换为大写

#include <stdio.h>
#include <stdlib.h>

void main( )
{
char file1[30],file2[30];
FILE *fpr,*fpw;
printf("Iuput the file names:\n");
scanf("%s%s",file1,file2);
if ((fpr=fopen(file1,"r"))==NULL)
{ printf("can't open file1\n");
exit(0); }
if ((fpw=fopen(file2,"w"))==NULL)
{ printf("can't open file2\n");
exit(0); }

while(!feof(fpr))
{if ((fgetc(fpr))>='a' && (fgetc(fpr))<='z')
fputc(fgetc(fpr)-32,fpw);
else
fputc(fgetc(fpr),fpw);}

fclose(fpr);
fclose(fpw);
}

这个程序错在哪里了?或者提供个正确的答案。。谢了谢了,急!

说明白点。。。表示能不能帮我修改一下。。

while(!feof(fpr))
{
char temp=fgetc(fpr);
if (temp>='a' && temp<='z')
fputc(temp-32,fpw);
else
fputc(temp,fpw);
}
你一个循环其实已经调用了fgetc三次 你的明白???改为temp暂时存储就可以了
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-12-29
不用fgetc(),直接用FREAD(),逐个判断就能搞定。
相似回答