Results for “pointer”
Small, practical examples. Search by task or narrow things down below.
Merge two sorted arrays
C: Advance the pointer belonging to the smaller next element and copy any remaining suffix.
C✓ Tested
Own one dynamically allocated value with unique_ptr
C++: make_unique allocates a value whose lifetime is tied to its owning smart pointer.
C++✓ Tested
Pass a function as a callback
C: A typed function pointer permits behavior to be supplied to another function.
C✓ Tested
Read a variant only when it holds the expected type
C++: get_if returns a null pointer rather than throwing for another active alternative.
C++✓ Tested
Reject an integer with trailing characters
Arduino / C: strtol exposes an end pointer so a parser can require the entire token.
Arduino / C✓ Tested
Return a status separately from a calculated result
C: An output pointer lets a function return success or failure independently of its numeric result.
C✓ Tested
Validate a complete numeric serial command
Arduino / C: Check for digits, an end pointer, and an application-specific range.
Arduino / C✓ Tested