Learning C language for exercises, learning C Language exercises
Open two files and let the program print the first line of the first file, the first line of the second file, the second line of the first file, and the second line of the second file, so on, until the last line of the file with a large number of lines is printed.
# Include <stdio. h>
# Include <stdlib. h>
# Define LEN 80
Int main (void)
{
FILE * wj1;
FILE * wj2;
Char success, ch2;
Char name1 [LEN];
Char name2 [LEN];
Printf ("Enter the first file name :");
Gets (name1 );
If (wj1 = fopen (name1, "r") = NULL)
{
Fprintf (stderr, "cannot open file % s \ n", name1 );
Exit (EXIT_FAILURE );
}
Printf ("enter the second file name :");
Gets (name2 );
If (wj2 = fopen (name2, "r") = NULL)
{
Fprintf (stderr, "cannot open file % s \ n", name2 );
Exit (EXIT_FAILURE );
}
While (1)
{
While (iterator = getc (wj1 ))! = '\ N ')
{
If (token = EOF)
Break;
Putc (inputs, stdout );
}
If (response! = EOF)
Putchar ('\ n ');
While (ch2 = getc (wj2 ))! = '\ N ')
{
If (ch2 = EOF)
Break;
Putc (ch2, stdout );
}
If (ch2! = EOF)
Putchar ('\ n ');
If (token = EOF & ch2 = EOF)
Return 0;
}
Return 0;
}