4
votes
Accepted
printf %s gives gibberish
(Community Wiki answer assembled from the comments)
Noting that the standard Arduino core doesn't have a Serial.printf() function. The ESP32 core does.
You need .c_str() in your calls. .printf() is a ...
Community wiki
4
votes
Accepted
Strange behavior from uint32_t, acting like signed int (Nano clone)
%d expects a signed int. %u expects an unsigned int. Insert the l modifier to expect a long in each of those cases. So you need a format code of %lu to print a uint32_t.
The following code:
#include &...
3
votes
Accepted
How to use a variable format in `sprintf`
sprintf cannot be used to write data into String objects. More precisely, it is possible to come up with a "hackish" way to write the result directly into a String object, but the latter is definitely ...
2
votes
Formatting of IP address via printf(...) family similar to Serial Object
There is also a one-line solution just as you wish. Instead of String(ip) use ip.toString().
IPAddress ip = WiFi.localIP();
char *buf = malloc(128);
sprintf(buf, "%s", ip.toString().c_str());...
2
votes
Strange behavior from uint32_t, acting like signed int (Nano clone)
*printf and bit-width specified types
#include <inttypes.h> or C++'s #include <cinttypes> counterpart (when you have it; not on AVR-based Arduinos) gives access to macros defined for the ...
1
vote
Porting the FastNoise c++ library to Due
The workaround is in the issue found by Jot.
In file
C:\Users\aaaaaa\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\c++\4.8.3\cstdio
comment ...
1
vote
Formatting of IP address via printf(...) family similar to Serial Object
"%u.%u.%u.%u", ip & 0xFF
instead of, should be
... "%u.%u.%u.%u", (ip>>0) & 0xFF,...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
printf × 10serial × 3
avr × 2
arduino-nano × 1
library × 1
arduino-due × 1
c × 1
memory × 1
pointer × 1