The fclose function is used to close an open FILE stream. If the stream was being used for output, any buffered data is written first.
#include <stdio.h>
int main () {
/* Local Declarations */
FILE * Input;
char C;
char FileName[20];
/* Initialization */
printf ("File name? ");
scanf ("%s", FileName);
Input = fopen (FileName, "r");
/* Algorithm */
fread (&C, 1, 1, Input);
while (!feof(Input)) {
fwrite (&C, 1, 1, stdout);
fread (&C, 1, 1, Input);
}
/* Finalization */
fclose (Input);
/* Report to system */
return 0;
}
| fopen | Open a FILE stream |
| fclose | HP 3000 Library Reference Manual |
| Closing Streams | The GNU C Library |
| fclose | The Open Group Base Specifications |
| feof | MSDN |
Copyright © 1999-2007, jhyoung,
revised 4/30/2007