Results for “extra”
Small, practical examples. Search by task or narrow things down below.
Deliver a result through a promise and future
C++: A promise sets a shared state and its future retrieves the value.
C++✓ Tested
Divide using a fractional number
C++: Use a floating-point operand to preserve the fractional part of a division.
C++✓ Tested
Divide using a fractional number
C: Use a floating-point operand to preserve the fractional part of a division.
C✓ Tested
Encode a byte buffer as hexadecimal
C: Format each byte as an unsigned two-digit hexadecimal value.
C✓ Tested
Explain a calculation with a comment
C++: Keep the code executable while documenting why a fixed input is used.
C++✓ Tested
Explain a calculation with a comment
C: Keep the code executable while documenting why a fixed input is used.
C✓ Tested
Filter an array in place with a write index
C: Only retained values advance the write position.
C✓ Tested
Filter and transform an array
Keep active objects and extract their names.
filter✓ Tested
Find a median element without fully sorting
C++: nth_element partitions around the element that would occupy the chosen sorted position.
C++✓ Tested
Find a substring
Check the result of std::string::find against npos.
C++✓ Tested
Find a substring
Use strstr to find a literal substring in a C string.
C✓ Tested
Find an array element
Use a bounded linear search over a C array.
C✓ Tested