include <stdio.h>
include <stdlib.h> /* EXIT_SUCCESS */
int nextline (FILE *fpin, FILE *fpout)
{
char line[BUFSIZ];
static int n = 0;
if (fgets (line, BUFSIZ, fpin) != NULL)
{
n++;
nextline (fpin, fpout);
fprintf (fpout, "%s", line);
}
else
printf (" %d Lines counted\n", n);
}
int main (int argc, char *argv[])
{
FILE *src;
FILE *dest;
if (argc != 3)
{
fprintf (stderr, "%s infilename outfilename\n", argv[0]);
exit (EXIT_FAILURE);
}
if ((src = fopen (argv[1], "r")) == NULL)
{
perror (argv[1]);
exit (EXIT_FAILURE);
}
if ((dest = fopen (argv[2], "w")) == NULL)
{
perror (argv[2]);
exit (EXIT_FAILURE);
}
nextline (src, dest);
return (EXIT_SUCCESS);
}