Possible Duplicate:
Extra leading zeros when printing float using printf?
I'm trying to get the output of this C program to have placeholder zeros, as the output of this program will be used as input for another program. Right now, I'm using the following print line.
fprintf(fp1, "06 BR%d%d %3.4f%3.4f%3.4f\n",i,d,X,Y,Z);
i = index for the loop
d = index for a second loop
X = double for a Cartesian system
Y = double for a Cartesian system
Z = double for a Cartesian system
Right now the output looks like this:
06 BR12 1.00001.00001.0000
I want it to be like the following:
06 BR0102 001.0000001.0000001.000
I know that I could just add placeholding zeros manually (if i<10, add a placeholder, etc.) but is there a more efficient way to output a placeholder zero than simply adding them in if-statements?
Thank you in advance.