This documentation is copyright © 1998-2001 Sandro Sigala <sandro@sigala.it>.
All rights reserved.

Released under the GNU General Public License.

Return to index Return to header Previous symbol Next symbol

fclose

Prototype

#include <stdio.h>

int fclose(FILE *stream);

Description

Flushes the stream pointed to by stream and closes the associated stream. Returns zero if the operation succeeds, or EOF if any errors were detected.

Example

View source
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    FILE *fout;

    if ((fout = fopen("test.txt", "w")) == NULL) {
	fprintf(stderr, "%s\n", strerror(errno));
	return EXIT_FAILURE;
    }
    fprintf(fout, "Test string\n");
    fclose(fout);

    return EXIT_SUCCESS;
}

References

ISO C 9899:1990 7.9.5.1