Results for “extra”
Small, practical examples. Search by task or narrow things down below.
Sort records by two fields
C++: Tuple comparison implements lexicographic ordering across several keys.
C++✓ Tested
Split comma-separated text
Use getline with a delimiter to split simple C++ text.
C++✓ Tested
Split simple delimited text in place
C: strtok inserts terminators into a writable buffer and skips repeated delimiter characters.
C✓ Tested
Store a reference in a standard container
C++: reference_wrapper preserves reference semantics while behaving like a copyable container element.
C++✓ Tested
Store a value in a named variable
C++: Give a value a descriptive name and print it.
C++✓ Tested
Store a value in a named variable
C: Give a value a descriptive name and print it.
C✓ Tested
Store a variable-length payload after a structure header
C: A flexible array member lets one allocation hold metadata and trailing bytes.
C✓ Tested
Store and inspect a fixed set of bits
C++: bitset offers named operations and a readable binary representation.
C++✓ Tested
Sum array values
Iterate over a fixed C array using a size-derived element count.
C✓ Tested
Sum the decimal digits of an unsigned integer
C: Repeated division and remainder extract digits without converting to text.
C✓ Tested
Sum vector values
Use std::accumulate with a wide initial value.
C++✓ Tested
Swap owned buffers by swapping their pointers
C: Pointer swaps avoid copying the underlying data.
C✓ Tested