I have a program that displays songs read in from a text file along with the time and displays them in a neat organized manner in the console. I’m having trouble however having an integer display 01 or 06 as opposed to 1 or 6 for my time format (00:00:00). How would i go about manipulating the output to display a zero infront of the integer when it is below 10?
An example output from my program:
SONG TITLE
The once and future carpenter 0:4:52
I never knew you 0:7:48
Life 0:10:52
February seven 0:15:0
My lfe 0:24:12
Yuor frei 0:37:20
Lisjlf 0:49:23
Lasifj 0:53:39
Longsong 1:9:2
Longer 1:22:3
Almost done 1:34:48
Process returned 0 (0x0) execution time : 0.280 s
Press any key to continue.
Desired Output:
SONG TITLE
The once and future carpenter 00:04:52
I never knew you 00:07:48
Life 00:10:52
February seven 00:15:00
My lfe 00:24:12
Yuor frei 00:37:20
Lisjlf 00:49:23
Lasifj 00:53:39
Longsong 01:09:02
Longer 01:22:03
Almost done 01:34:48
Process returned 0 (0x0) execution time : 0.280 s
Press any key to continue.
And how do you display your values? Using stream utilities provided by standard library? if so, you could use
setwmanipulator in conjunction withsetfill.stdiocounterparts also allow specifying of widht and fill, using appropriate flags with format specifier: