Results for “eof”
Small, practical examples. Search by task or narrow things down below.
Narrow a union using typeof
Handle text and numeric values with separate branches.
union✓ 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
Narrow an object with a pattern variable
Java: Pattern matching avoids a separate cast after a successful instanceof check.
Java✓ Tested
Allocate and free a typed array
C: Use sizeof on the pointed-to type and check allocation success before writing.
C✓ Tested
Convert Unix seconds into an aware UTC timestamp
PowerShell: DateTimeOffset.FromUnixTimeSeconds creates a value with an explicit UTC offset.
PowerShell✓ Tested
Convert Unix seconds to an offset-aware timestamp
C#: DateTimeOffset preserves the UTC offset explicitly.
C#✓ Tested
Count newline characters
Count newline bytes in a C file while retaining EOF as an int.
C✓ Tested
Iterate over a fixed array of records
C: Compute the array element count with sizeof at the point where it is still an array.
C✓ Tested
Read a file without losing its last line
Handle spaces, backslashes, and a final line without a newline.
read lines✓ 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