Results for “extra”
Small, practical examples. Search by task or narrow things down below.
Use a last-in first-out stack
C++: Read top before pop because pop does not return the removed value.
C++✓ Tested
Use an automatically removed temporary file
C: tmpfile creates a binary update stream whose file is removed when closed.
C✓ Tested
Validate a complete floating-point input
C: strtod exposes both the stopping position and range errors; reject nonfinite results when required.
C✓ Tested
Validate a complete identifier
C++: regex_match requires the pattern to match the complete input sequence.
C++✓ Tested
Validate a simple C-style ASCII identifier
C: Check the first character separately from subsequent characters and reject empty input.
C✓ Tested
Visit every item in a collection
C++: Print each element in the collection’s original order.
C++✓ Tested
Visit every item in a collection
C: Print each element in the collection’s original order.
C✓ Tested
Wait for shared state with a condition variable
C++: Use a predicate so spurious wakeups cannot allow the worker to continue before the state is ready.
C++✓ Tested
Write a text file
Write and close a C++ output file while checking stream failure.
C++✓ Tested
Write a text file
Open, write, and close a C file while checking every operation.
C✓ Tested
Write and read binary bytes
Round-trip a byte buffer through a C binary file.
C✓ Tested
Write and read bytes without text conversion
C++: Use binary stream modes and check each I/O operation before consuming its result.
C++✓ Tested