How to add in commas to output after reading a number from a file?

For example, the file says 13144
After reading in the number, how do I print it out so it says "13,144"?

The complete assignment is this:

Lab Exercise #6
Put your name, the compiler and operating system used, and Exercise #6 in a comment at the top of your program. This lab exercise is also due Thursday at 11:30.

Write a program to read the input file below, consisting of 9 records and produce the output shown. The input data must be stored in a 9 element array of structs with 3 members. Include 2 functions besides main(). One function should read in the data and the second function should write it out.

Input file

Barry 12345 67.23
Cary 543210 19.27
Gary 654321 777.32
Harry 123456 500
Jerry 19 100.02
Larry 234567 999.99
Mary 345678 234.56
Perry 789 1.24
Terry 123456 876.3

Output

Barry 12,345 $67.23
Cary 543,210 $19.27
Gary 654,321 $777.32
Harry 123,456 $500.00
Jerry 19 $100.02
Larry 234,567 $999.99
Mary 345,678 $234.56
Perry 789 $1.24
Terry 123,456 $876.30

Last edited on
The Standard Library provides methods to do this. Does your professor expect you to use the Standard Library to do the formatting or are you supposed to format it on your own?



[edit]
Also, why do people take the time to create a screenshot, upload it to another site, create a link to said image, and post that, instead of just copy-n-pasting the text of the assignment itself?

People don’t want to answer a question that is going to disappear.
Last edited on
I'm assuming it's ok to use the Standard Library for this(since the assignment instructions don't forbid it)



and yea, I fixed it. I thought a picture of the assignment would look clearer.
Topic archived. No new replies allowed.