You’re right… I know how to get around it, but it’s not pretty; primarily because of the leading 0 on the decimal portion of the number.
···
Hi,
In message “Is %f formatting broken?” > on 02/11/27, “Ted” ted@datacomm.com writes:
sprintf (“%d days %02d:%02d:%02.6f”,@DD,@hh,@mm,@ss)
produces:
537 days 22:05:10.081386 until Teddy gets his learner’s permit
537 days 22:05:9.081456 until Teddy gets his learner’s permitI intended for the seconds to be right-justified and zero-filled.
But that’s how printf(3) works.
% cat c.c
main(){
printf(“%d days %02d:%02d:%02.6f\n”,537,22,5,9.09);
}
% gcc c.c
% a.out
537 days 22:05:9.090000matz.