string format func


Recommended Posts


Isn't this function applied directly to the String variable?


Although it applies when used like this,

String ex;

ex = ex.format(" value %d", 3);


but, Are there any format functions that apply right away?
Like CString's Format.


As a result of the tests, it seems to be applied when using the printf function.

Edited by dongju.jeong
Link to post

it work like spritf

String ex = String::format(" value %d", 3); // "value 3"
const char *m = String::format("value float %.2f", 12.342532f).get(); //"value float 12.34"

its static method, you can call it without instance

  • Like 1
Link to post

Yes, like cash-metall mentioned, format() is a static method.

To apply formatting to the calling instance you should use printf()/vprintf().

String ex;

ex.printf(" value %d", 3);


  • Like 1
Link to post