FIND YOUR NEXT FEW LINES

The snippet library.

Small, practical examples. Search by task or narrow things down below.

10 snippets foundClear filters
Arduino / CText & bounded buffers

Compare a command case-sensitively

Arduino / C: strcmp returns zero when both null-terminated strings match.

Arduino / C✓ Tested
Arduino / CText & bounded buffers

Copy a string with a guaranteed terminator

Arduino / C: Reserve one character for the terminator when copying a bounded string.

Arduino / C✓ Tested
Arduino / CText & bounded buffers

Detect truncated formatted output

Arduino / C: snprintf returns the length it would have written, excluding the null terminator.

Arduino / C✓ Tested
Arduino / CText & bounded buffers

Extract a section of an Arduino String

Arduino / C: substring includes the start index and excludes the end index.

Arduino / C✓ Tested
Arduino / CText & bounded buffers

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
Arduino / CText & bounded buffers

Keep a serial message in flash memory

Arduino / C: The F macro keeps a literal out of scarce SRAM.

Arduino / C✓ Tested
Arduino / CText & bounded buffers

Reject an integer with trailing characters

Arduino / C: strtol exposes an end pointer so a parser can require the entire token.

Arduino / C✓ Tested
Arduino / CText & bounded buffers

Replace a token inside an Arduino String

Arduino / C: replace modifies all occurrences in the existing object.

Arduino / C✓ Tested
Arduino / CText & bounded buffers

Split a writable comma-delimited buffer

Arduino / C: strtok modifies its buffer and returns successive tokens.

Arduino / C✓ Tested
Arduino / CText & bounded buffers

Trim surrounding whitespace from an Arduino String

Arduino / C: String.trim modifies the object in place.

Arduino / C✓ Tested