sprintf
Form a string according to the printf principle.
Call:
string sprintf( string format, value);
Example. Output a chilo with two decimal places.
string sresult = sprintf("%.2f", 2.024);
As a result, the sresult variable will contain the string "2.02".
Else example
Desired result |
Format |
Parameter type |
Construction example |
001 |
"%03i" |
int |
int m = 10; string s = sprintf("%03i",m); |