Results for “C”
Small, practical examples. Search by task or narrow things down below.
Use a fallback for a missing hashtable entry
PowerShell: Test the key explicitly so legitimate false or zero values are preserved.
PowerShell✓ Tested
Use a fallback for an unset variable
Bash Scripts: Use a fallback for an unset variable with a small standalone Bash program.
Bash Scripts✓ Tested
Use a fixed-size container with bounds checking
C++: std::array retains its element count and supports checked access through at.
C++✓ Tested
Use a function’s exit status as a boolean result
Bash Scripts: Return zero for success and test the function directly in a conditional.
Bash Scripts✓ Tested
Use a hash map for direct key lookup
C++: unordered_map provides key lookup without promising iteration order.
C++✓ Tested
Use a last-in first-out stack
C#: Stack is useful for reversible traversal and other nested operations.
C#✓ Tested
Use a last-in first-out stack
C++: Read top before pop because pop does not return the removed value.
C++✓ Tested
Use a nonnegative remainder for cyclic indexing
Use a nonnegative remainder for cyclic indexing in a complete Rust program using the standard library.
Rust✓ Tested
Use a recursive function for a bounded calculation
Bash Scripts: A recursive factorial demonstrates local variables and a clear base case.
Bash Scripts✓ Tested
Use a session-scoped temporary table
Store intermediate rows in a local # table.
temporary table✓ Tested
Use a switch expression to classify a value
C#: Relational patterns express a small ordered range classification.
C#✓ Tested
Use a wider type for a large count
Arduino / C: Use a wider type for a large count on an Uno with the Serial Monitor set to 9600 baud.
Arduino / C✓ Tested