Clearerr (clear file stream error flag)
Correlation function feof
Table header file #include <stdio.h>
Defines the function void Clearerr (FILE * stream);
The function Description Clearerr () Clears the error flag used by the file stream specified by the parameter stream.
return value
Fclose (Close file)
Correlation function Close,fflush,fopen,setbuf
Table header file #include <stdio.h>
define function int fclose (FILE * stream);
The function Description fclose () is used to close the previously fopen () Open file. This action will cause the data in the buffer to be written to the file and release the file resources provided by the system.
The return value returns 0 if the closed file action succeeds, and returns EOF when an error occurs and saves the error code to errno.
The error code EBADF represents a file that is not open for the parameter stream.
Please refer to fopen () for examples.
Fdopen (converting file descriptors to file pointers)
Correlation function Fopen,open,fclose
Table header file #include <stdio.h>
Defines the function FILE * fdopen (int fildes,const char * mode);
The function Description Fdopen () Converts the file descriptor of the parameter fildes to the corresponding file pointer and returns. The argument mode string represents the flow pattern of the file pointer, which must be the same as the original file description Word read and write mode. Refer to fopen () for the mode string format.
Returns a file pointer to the stream when the return value conversion succeeds. Failure returns null and the error code exists in errno.
Example
#include<stdio.h>
main()
{
FILE * fp =fdopen(0,”w+”);
fprintf(fp,”%s\n”,”hello!”);
fclose(fp);
}
Execute hello!
Feof (check that the file stream is read to the end of the file)
Correlation function Fopen,fgetc,fgets,fread
Table header file #include <stdio.h>
define function int feof (FILE * stream);
Function Description feof () is used to detect whether the end of the file is read, and the mantissa stream is the file pointer returned by fopen (). Returns a value other than 0 if it is at the end of the file, and returns 0.
The return value returns a value other than 0 that represents the end of the file that has reached.