The snippet library.
Small, practical examples. Search by task or narrow things down below.
Compare a command case-sensitively
Arduino / C: strcmp returns zero when both null-terminated strings match.
Arduino / C✓ Tested
Copy a string with a guaranteed terminator
Arduino / C: Reserve one character for the terminator when copying a bounded string.
Arduino / C✓ Tested
Detect truncated formatted output
Arduino / C: snprintf returns the length it would have written, excluding the null terminator.
Arduino / C✓ Tested
Extract a section of an Arduino String
Arduino / C: substring includes the start index and excludes the end index.
Arduino / C✓ Tested
Format several integers in a fixed buffer
Arduino / C: snprintf limits writes to the buffer size and includes a terminating null byte.
Arduino / C✓ Tested
Keep a serial message in flash memory
Arduino / C: The F macro keeps a literal out of scarce SRAM.
Arduino / 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
Replace a token inside an Arduino String
Arduino / C: replace modifies all occurrences in the existing object.
Arduino / C✓ Tested
Split a writable comma-delimited buffer
Arduino / C: strtok modifies its buffer and returns successive tokens.
Arduino / C✓ Tested
Trim surrounding whitespace from an Arduino String
Arduino / C: String.trim modifies the object in place.
Arduino / C✓ Tested