Home > Back-end > Fseek why always moved to the end and not only when migration?
Fseek why always moved to the end and not only when migration?
Time:01-06
Every time is, no matter how many byte offset, why not move to # before writing, please? Writing is wanananan that paragraph,
CodePudding user response:
This writing can only modify memory first, and then to flash files (disk orflash), cannot be directly inserted into the ~ in the file
CodePudding user response:
File originally what Do you want to get into what Your code is what File into what
Only information from point of view, everything is normal, is your expectations or wrong understanding of file operations,
CodePudding user response:
Please look at the third parameter
The fseek and _fseeki64 functions provides The moves The file pointer (if any) associated with stream to a new location that is offset bytes from origin. The next operation on The stream takes place at The new location. On a stream open for update, The next operation can be either a read or write. "The argument of origin must be one of The following constants, defined in The STDIO, H:
SEEK_CUR The Current position of the file pointer.
SEEK_END The End of the file.
SEEK_SET Beginning of the file.
You can use fseek and _fseeki64 to reposition the pointer anywhere in a file. The pointer can also be positioned beyond the end of the file. The fseek and _fseeki64clears the end - of - file indicator and negates the effect of any prior ungetc calls against the stream.
When a file is the opened for appending data to the current file position is determined by the last I/O operation, not by the where the next write order to occur. If no I/O operation has yet occurred on a file the opened for appending, the file position is the start of the file.