Results for “extra”
Small, practical examples. Search by task or narrow things down below.
Parse an integer with validation
Validate range and trailing characters when parsing a C integer with strtol.
C✓ Tested
Parse an unsigned hexadecimal integer
C: Use an explicit base and check both range and full consumption.
C✓ Tested
Pass a function as a callback
C: A typed function pointer permits behavior to be supplied to another function.
C✓ Tested
Pass an argument into a worker thread
C++: Thread arguments are copied by default; std::ref explicitly passes a reference.
C++✓ Tested
Pass values through a custom event
jQuery: trigger passes its extra argument array after the event object.
jQuery✓ Tested
Preserve equal-key order while sorting records
C++: stable_sort retains encounter order for records whose selected sort keys compare equal.
C++✓ Tested
Print a number with two decimal places
C++: Format a small decimal value consistently for display.
C++✓ Tested
Print a number with two decimal places
C: Format a small decimal value consistently for display.
C✓ Tested
Print only the matching portions
Linux Commands: Use extended regex and -o to extract digit sequences.
Linux Commands✓ Tested
Process a first-in first-out queue
C++: Queue exposes its front item separately from the operation that removes it.
C++✓ Tested
Protect a shared container with a mutex
C++: A scoped lock_guard releases the mutex when its scope ends.
C++✓ Tested
Quote a CSV field and double embedded quotes
C: A quoted CSV field represents a quote character by repeating it.
C✓ Tested