C library function - fclose()
Description
C library function *int fclose(FILE stream) Closes the stream. Flushes all buffers.
Declaration
The following is the declaration of the fclose() function.
int fclose(FILE *stream)
Parameters
- stream -- This is a pointer to a FILE object that specifies the stream to be closed.
Return Value
If the stream is closed successfully, the method returns zero. If it fails, it returns EOF.
Example
The following example demonstrates the use of the fclose() function.
Example
#include
int
main
(
)
{
FILE
fp
;
fp
=
fopen
(
"file.txt"
,
"w"
)
;
fprintf
(
fp
,
"%s"
,
"This is runoob.com"
)
;
fclose
(
fp
)
;
return
(
0
)
;
}
Let us compile and run the program above, which will create a file file.txt, then write the following lines of text, and finally use the fclose() function to close the file.
这里是 runoob.com
C Standard Library -