#include < stdio.h >
#define N 10
Main ()
{
int exit (int); /*exit () function prototype */
FILE * in, * out;
Char Ch,infile[n],outfile[n];
printf ("Please input infile name:");
scanf ("%s", infile);
ch = getchar (); /* Used to reclaim the last carriage return entered when executing scanf ("%s", infile) statement */
printf ("Please input outfile name:");
scanf ("%s", outfile);
ch = getchar ();/* Used to reclaim the last carriage return entered when executing scanf ("%s", outfile) statement */
if (in = fopen (infile, "R")) = = = NULL)
{
printf ("Can not open infile.");
Exit (0);
}
if (out = fopen (outfile, "w")) = = = NULL)
{
printf ("Can not open outfile.");
Exit (0);
}
while (. feof ())/*feof (in) is used to determine whether the in file is currently in the end state (that is, feof (in) =1), and if so, the fclose (in) statement after which the while loop is executed; If the in file is not currently in the end state (that is, feof (in) =0), execute the FPUTC (fgetc (in), out) statement in the while loop */
FPUTC (Fgetc (in), out);
Fclose (in);
Fclose (out);
}
FPUTC (character to be output, file pointer variable): The file to which the "to output character" is pointed to by "file pointer variable" is a filename;
FGETC (file pointer variable): reads a character from the "file pointer variable";
The following is the correct wording:
FPUTC (fgetc (file pointer variable 1), file pointer variable 2), which means reading a character from the file pointed to in "File pointer variable 1", and then writing to the file pointed to in "File pointer variable 2" and saving.