A
abubakarm
Hi,
How can I write a number 123456 formatted as 123,456 using printf?
Regards,
...ab
How can I write a number 123456 formatted as 123,456 using printf?
Regards,
...ab
Hi,
How can I write a number 123456 formatted as 123,456 using printf?
Regards,
..ab
Hi,
How can I write a number 123456 formatted as 123,456 using printf?
How can I write a number 123456 formatted as 123,456 using printf?
And how do I set the locale of a ostream and use it too ?
Hi,
How can I write a number 123456 formatted as 123,456 using printf?
Regards,
Two people have given you an incorrect answer roughly corresponding to
this:
int x = 123456; // assumes int has > 16 bits, not guaranteed
printf("%d,%d", x / 1000, x % 1000);
...which will give you "123,456".
But if 'x' is 123001, they will output the obviously incorrect:
"123, 1".
And how do I set the locale of a ostream and use it too ?
On 27 Mar 2007 23:50:34 -0700, (e-mail address removed) wrote in
comp.lang.c++:
Two people have given you an incorrect answer roughly corresponding to
this:
int x = 123456; // assumes int has > 16 bits, not guaranteed
printf("%d,%d", x / 1000, x % 1000);
...which will give you "123,456".
But if 'x' is 123001, they will output the obviously incorrect:
"123, 1".
The correct conversion specifier is "%d,%03d".
oh, c'mon.. he was asking about 123456![]()
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.