/*
Function: Set file offset location
Parameter 1:file Flow
Parameter 2: Offset
Parameter 3: Offset position: Seek_set, seek_cur, seek_end
Return value: Returns 0 successfully, otherwise returns 1 and sets errno
*/intlongint whence);
/*
Function: Determine the location of the file location pointer
Parameter 1:file Flow
return value: The current position of the file location pointer, otherwise return-1, and set errno*/ long ftell (FILE *stream); /*
Function: File location pointer definition to file start location
Parameter 1:file Flow
return value: None
*/void Rewind (FILE *stream);
The program for determining file size using the Fseek function and the Ftell function:
#include <stdio.h>#include<stdlib.h>intMainintARGC,Char**argv) {FILE*FP; if(ARGC <2) {fprintf (stderr,"usage....\n"); Exit (1); } FP= fopen (argv[1],"R"); if(fp = =NULL) {Perror ("fopen ()"); Exit (1); } fseek (FP,0, Seek_end); printf ("%ld\n", Ftell (FP)); Exit (0);}
Using the fseek function to produce an empty file
/* Function: Refreshes a stream
Parameter 1:file stream, if null, refreshes all stream
*/ int fflush (FILE *stream);
Buffer function: Merging system calls
Line buffer: Refresh when line breaks, full time brush, Force refresh (stdout)
Full buffer: Full time brush, Force refresh (default, except stdout)
Unbuffered: Content that needs to be output immediately (stderr)
To set the buffering mode:
int Char int mode, size_t size);
Fourth day-----file location function and buffer refresh function