Read a line of text at a time and format it

I will be having input files that are supposed to be formatted like this
xxxxxxxxx,xxx
xxxxxxxxx,xxx
xxxxxxxxx,xxx

Where the first set of 9 numbers is a id and the last set of numbers is quantity.
It is known that sometimes if the number starts with a 0 on an id, it will leave it off, so I need to make sure the first digit is exactly 9 digits long.

And these numbers are all in an input file that as about a thousand on the page. I need it to read and reformat them all to follow that guide.


Just show me in the right direction. Thank you
You can use the setw() and setfill() manipulators to help format that first entry if you are handling your ID numbers as numbers instead of strings. I really suggest you consider treating your ID number as a string instead of a number, then you probably won't have the problems of dropping off the leading zeros.

Topic archived. No new replies allowed.