How to format int 1 to string 0001 in C++?
Hi guys,
In C++ as subjected, can anyone throw me some light on how I can generic-ly format an integer value of 1 to a string value of 0001? 11 to 0011? and 111 to 0111? simply by just appending 0 in front and limiting the length of the string to 4? Much Thanks! Chinho |
Maybe messing around with std::fixed and std::setprecision?
|
I'm sorry, here is what you need to use:
Code:
int mynumber = 1; |
Thanks corp!
|
Not a problem at all, glad to see it worked for you. Thanks for asking too, it gives me something to do!
|
All times are GMT -5. The time now is 07:23 AM. |