FPUTC () and the use of the fgetc () function

Source: Internet
Author: User
Tags function prototype
#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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.