3 ms·
The terminating character is still the closing double quote and not a null, since the library does neither copy out nor alter the input. For example tiny_json r
by jeffreygoesto 2y ago
The terminating character is still the closing double quote and not a null, since the library does neither copy out nor alter the input. For example tiny_json replaces the closing quotes to create C strings, but that needs the full file to be in a mutable buffer which can be prohibitive for small controllers reading some config from flash only.
- jdougan 2y agoWith the "%.*s" format you need no null at the end. It just counts out the characters: #include <stdio.h> void main() { char buff[10] = {'R', 'o', 'b', 'o', 't', 't', 'y', 'p', 'e', 's'}; printf("=>%.*s<=", 4, ((char *)&buff + 3)); } prints =>otty<=
- jeffreygoesto 2y agoAh. Ok. Scanning the length before printing is mandatory then.