A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/cstdio/fclose/ below:

function

<cstdio>

fclose
int fclose ( FILE * stream );

Close file

Closes the file associated with the stream and disassociates it.

All internal buffers associated with the stream are disassociated from it and flushed: the content of any unwritten output buffer is written and the content of any unread input buffer is discarded.

Even if the call fails, the stream passed as parameter will no longer be associated with the file nor its buffers.



Parameters
stream
Pointer to a FILE object that specifies the stream to be closed.

Return Value If the stream is successfully closed, a zero value is returned.
On failure, EOF is returned.

Example
1
2
3
4
5
6
7
8
9
10
/* fclose example */
#include <stdio.h>
int main ()
{
  FILE * pFile;
  pFile = fopen ("myfile.txt","wt");
  fprintf (pFile, "fclose example");
  fclose (pFile);
  return 0;
}

This simple code creates a new text file, then writes a sentence to it, and then closes it.

See also
fopen
Open file (function)
fflush
Flush stream (function)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4