sprintf formatting specifers

Where are the sprintf formatting specifiers listed?

I looked in the examples, samples, guides, references, and there's nothing listed.

For example a function with the signature that returns:

unsigned long getEpochTime() const;

With the function:

[tt]​[/tt]  Serial.println(timeClient.getEpochTime()); // compiles ok

  String path = sprintf("/system-test/%lu", timeClient.getEpochTime()); // fails to compile

Fails to compile with the error:

​​ error: invalid conversion from 'int' to 'const char*' [-fpermissive]

Is there some documentation about which stdlib the Arduino Create UI uses? The forum docs only provide this link: avr-libc: <stdio.h>: Standard IO facilities

Sorry to ask this question, especially on a forum like this where everyone seems to angry :slight_smile:

OK found it, don't use sprintf, use String()

  String path = String("/system-test/" + String(timeClient.getEpochTime()));

The ideal choice is snprintf_P.

You use it wrong, here is sprintf documentation
http://www.cplusplus.com/reference/cstdio/sprintf/

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.