#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LEN 40
//abc-1.txt abc-2.txt
int main()
{
FILE *in, *in1;
int ch1,ch2,i;
char name[LEN];
char name1[LEN];
fprintf(stdout, "input your filename,name1 name2:");
scanf("%s %s",&name,&name1) ;文章来源:https://www.toymoban.com/news/detail-816680.html
if ((in = fopen(name, "r")) == NULL)
{
fprintf(stderr, "I couldn't open the file \"%s\"\n",name);
exit(EXIT_FAILURE);
}
if ((in1 = fopen(name1, "r")) == NULL)
{
fprintf(stderr, "I couldn't open the file \"%s\"\n",name);
exit(EXIT_FAILURE);
}
printf("A:\n");
while(feof(in1)==0 || feof(in)==0)
{
while((ch1=getc(in))!='\n'&&ch1!=EOF)
putchar(ch1);
if(ch1=='\n')
putchar('\n');
while((ch2=getc(in1))!='\n'&&ch2!=EOF)
putchar(ch2);
if(ch2=='\n')
putchar('\n');
}
printf("\n");
fseek( in, 0, SEEK_SET );
fseek( in1, 0, SEEK_SET );
printf("B:\n");
while(feof(in1)==0 || feof(in)==0)
{
while((ch1=getc(in))!='\n'&&ch1!=EOF)
putchar(ch1);
while((ch2=getc(in1))!='\n'&&ch2!=EOF)
putchar(ch2);
if(ch2=='\n')
putchar('\n');
}
printf("\n");
fclose(in);
fclose(in1);
return 0;
} 文章来源地址https://www.toymoban.com/news/detail-816680.html
到了这里,关于C Primer Plus(第六版)13.11 编程练习 第7题的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!