#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
FILE *fin,*fout;
char str1[81],str2[81]; //假定每行不超过80个字符
char *infile = "in.txt";
char *outfile = "out.txt";
fin = fopen(infile,"r"); // 读格式打开,默认为文本类型
fout = fopen(outfile,"w"); // 写格式打开,默认为文本类型
if((fin == NULL) || (fout == NULL)) {
printf("打开文件失败!\n");
exit(1);
}
while(fscanf(fin,"%s",str1) == 1) {
// 在这儿处理串str1......
strcpy(str2,str1);
fprintf(fout,"%s",str2); // 写入文件
}
fclose(fin);
fclose(fout);
return 0;
}
温馨提示:答案为网友推荐,仅供参考