while ( ( ch = fgetc(fp1) ) != EOF ) /* 从文件fp1中读字符 */ fputc (ch, fp2); /* 写入文件fp2中 */ fclose (fp1); /* 关闭两个文件 */ fclose (fp2); } 12.3.2 文件的字符串输入/输出函数 对文件的输入输出,除了前面介绍的以字符为单位进行处理之外,还允许以字符串为单位进行处理,这...
fp1 = fopen(argv[1],"r"); if(fp1==NULL){ printf("source file1 open error"); exit(1); } fp2 = fopen(argv[2],"r"); if(fp1==NULL){ printf("source file2 open error"); exit(1); } fp3 = fopen(argv[3],"w"); if(fp1==NULL){ printf("target file3 open error"); exit(...
问答题 CB1+2=3DZX7*8!! 则下列程序运行后D盘上的B.txt文件的内容为___ #include#includeint main( ){ int c; FILE *fp1,*fp2; if((fp1=fopen("D:\\A.txt","r"))==NULL) { printf("file error!"); exit(0); } if((fp2=fopen("D:\\B.txt","w"))==NULL) { printf("file error...
fp1 = fopen(argv[1],"r"); if(fp1==NULL){ printf("source file open error"); exit(1); } intch; while((ch=fgetc(fp1)) != EOF){ chars++; if(ch=='\n') row++; if(IS_WHITE_SPACE(ch)){ word++; } } //关闭流 if(fclose(fp1)!=0){ printf("source file close error"); }...
if(fp1==NULL){ printf("source file open error"); exit(1); } fp2 = fopen(argv[2],"w"); if(fp2==NULL){ printf("target file open error"); exit(1); } intch; while((ch=fgetc(fp1)) != EOF){ fputc(ch, fp2); } //关闭流 ...
if((fp1=fopen("test.txt","wb"))==NULL) { printf("不能打开文件"); exit(0); } printf("请输入信息,姓名 年龄 分数1 分数2 地址:\n"); for( i=0;i<2;i++) { scanf("%s %d %f %f %s",stu.name,&stu.age,&stu.score[0],&stu.score[1], stu.addr); ...