#include <stdio.h>
#include <stdlib.h>
#define MAXLINE 150
void cross_read_line(char * file1, char * file2, char * mode);
int main(int argc,char *argv[])
{
cross_read_line(argv[1], argv[2], "rw");
return 0;
}
/* 以行为单位,交替输出两文件(按行)内容 */
void cross_read_line(char * file1, char * file2)
{
FILE * fp1, * fp2;
char line1[MAXLINE];
if ((fp1 = fopen(file1,"rb")) == NULL){
fprintf(stderr,"Can't open %s/n",file1);
exit(1);
}
if ((fp2 = fopen(file2,"ab")) == NULL){
fprintf(stderr,"Can't open %s/n",file2);
exit(1);
}
while (fgets(line1,MAXLINE,fp1) != NULL)
{
fputs(line1 + 6,fp2);
}
fclose(fp1);
fclose(fp2);
}