#include using namespace std; int main() { FILE *fp1,*fp2; char ch; if ((fp1=fopen("s1.txt","r"))==NULL) { cout<<"can not open s1.txt\n"; return 0; } if ((fp2=fopen("d1.txt","w"))==NULL) { cout<<"can not open d1.txt\n"; return 0; } ch=fgetc(fp1); while(ch!=EOF) //判断是否读到文件结尾 { if((ch>='a')&&(ch<='z')) { ch=ch-32; } fputc(ch,fp2); //输出到文件中 ch=fgetc(fp1); } fclose(fp1); fclose(fp2); return 0;

完善程序:从文本文件s1txt中读入多行字符到内存将其中的小写字母全改成大写字母然后输出到文本文件d1txt中。#include iostreamusing namespace std;int main FILE fp1fp2; char ch; if fp1=fopens1txtr==NULL coutcan not open s1txtn;

原文地址: http://www.cveoy.top/t/topic/fEDR 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录