Results for “File positioning & lifecycle”
Small, practical examples. Search by task or narrow things down below.
Copy a file in bounded binary chunks
C: Check read, write, and close errors while copying without loading the entire file.
C✓ Tested
Handle a missing file without treating it as an empty file
C: Inspect errno after a failed fopen to distinguish the documented missing-path condition.
C✓ Tested
Measure a small seekable binary file
C: Seek to the end and inspect ftell, checking both operations for errors.
C✓ Tested
Read bytes from a chosen file offset
C: Check fseek before reading so an unsupported or invalid seek is not ignored.
C✓ Tested
Remove one known scratch file
C: Check remove’s return value instead of assuming deletion succeeded.
C✓ Tested
Rename a known file
C: The standard rename function reports failure through its return value.
C✓ Tested
Replace bytes at a known position in a binary file
C: Open in update mode and seek before writing a fixed-size replacement.
C✓ Tested
Use an automatically removed temporary file
C: tmpfile creates a binary update stream whose file is removed when closed.
C✓ Tested
Read a stream again from its beginning
C: rewind returns a seekable stream to offset zero and clears its error and EOF indicators.
C✓ Tested
Read characters without confusing EOF with a byte
C: Store fgetc in int so every unsigned-char value remains distinguishable from EOF.
C✓ Tested
Add a forgotten file to the latest unpublished commit
Git: Stage the missing file before amending without changing the message.
Git✓ Tested
Append a line to a file
Add a new line to the end of a text file without replacing its existing contents. Append mode also creates the file if it does not exist.
file✓ Tested