04.04.2013, 13:03
Quote:
Not sure how well known this is, only just figured this out for myself.
I wanted to limit the length of a string in a format, and usually I would have a separate string of the needed length, or use strmid, but I figured out that it can be done in format just like it can be done with floats. This would show a float as a maximum of 4 decimal points. Код:
format(str, sizeof(str), "%0.4f", somefloat); Код:
format(str, sizeof(str), "%10s", somestring); Код:
format(str, sizeof(str), "%0.10s", somestring); Sorry if this is old news. |
I think this would be more fitting in the Tips & Tricks thread, though.