C examples for stdio.h:fclose
function
<cstdio> <stdio.h>
int fclose ( FILE * stream );
Closes the file. All internal buffers for the stream are disassociated from it and flushed.
Parameter | Description |
---|---|
stream | Pointer to a FILE object that specifies the stream to be closed. |
If the stream is successfully closed, a zero value is returned. On failure, EOF is returned.
This following code creates a new text file, then writes a sentence to it, and then closes it.
#include <stdio.h> int main (){/*from w ww .j a v a 2 s .c o m*/ FILE * pFile; pFile = fopen ("main.cpp","wt"); fprintf (pFile, "test"); fclose (pFile); return 0; }