tags:

views:

178

answers:

1

I have output like this:

1569.3669
15968.3699
41.3878
587.5401

but I want the output like this:

01569.3669
15968.3699
00041.3878
00587.5401

How can I do this in the C language?

+7  A: 
printf("%010.4f", val);

Should do it for you, where val is each value. For more info see here

Edit: Thanks Barry.

mdec
Using a leading zero is the correct idea, but the number to the left of the decimal point is the width of the entire number (integer plus decimal portion, including the decimal point itself). The correct format code is %010.4f
Barry Brown