There was a problem with printing integers with thousands / million separators.
I have a text file in which I received the country, city, general population.
I need to read in a file and sort by country. If the country is eual, I have to sort in descending order of population.
The text file is similar:
Australia ........ Sydney ......... 10.123.456
Brazil ........... Sao Paulo ....... 7.123.345
I read all 3 in a separate line. Then I delete everything. "" in the population line. Then I use atoi () to group the population chain.
Now I can sort by population if the country is equal. This view is working correctly.
So far so good. But I need the thousand / millionth separator to go to the press of the population.
If I use a string with "." For the public, sorting does not work correctly. Its sorting:
x ........ x ...... 1.123456
x ........ x ...... 10.123.456
x ........ x ...... 2.123.232
It should look like this:
Australia ........ Sydney ......... 10.123.456
Australia ........ Brisbane ....... 8.123.456
Is there a way to manipulate printing by adding a separator to int again?
Thank you very much in advance
c ++ separator fstream
d0zer Jul 08 '13 at 15:26 2013-07-08 15:26
source share