Results for “extra”
Small, practical examples. Search by task or narrow things down below.
Choose between two branches
C: Use if and else to handle an available or empty stock count.
C✓ Tested
Clamp a value to a range
Use C++17 clamp to bound a numeric value.
C++✓ Tested
Clamp an integer to inclusive bounds
C: Explicit comparisons avoid relying on nonstandard min or max macros.
C✓ Tested
Clear an owning pointer after releasing its allocation
C: Assigning NULL helps prevent accidental reuse through the same variable.
C✓ Tested
Combine text with a name
C++: Construct a greeting from a fixed prefix and a stored name.
C++✓ Tested
Combine text with a name
C: Construct a greeting from a fixed prefix and a stored name.
C✓ Tested
Compare a value with a limit
C++: Turn a comparison into a readable yes or no result.
C++✓ Tested
Compare a value with a limit
C: Turn a comparison into a readable yes or no result.
C✓ Tested
Compare binary buffers including zero bytes
C: memcmp checks an explicit byte length rather than stopping at a string terminator.
C✓ Tested
Compare small floating-point results with a tolerance
C: Use an absolute difference threshold for this known bounded magnitude.
C✓ Tested
Compare two C strings for equality
C: strcmp returns zero only when both null-terminated byte strings are equal.
C✓ Tested
Compute a simple XOR checksum
C: XOR all payload bytes into one byte to demonstrate a basic error-detection field.
C✓ Tested