Sign in to follow this  
photo

string format func

Recommended Posts

image.thumb.png.de5ea3adfda698150fdf87b6643d6a79.png

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

Share this post


Link to post

it work like spritf

String ex = String::format(" value %d", 3); // "value 3"
//or
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

Share this post


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);

Thanks!

  • Like 1

Share this post


Link to post

Thank you.

Share this post


Link to post
Sign in to follow this