How to write extra leading zeros when printing float in printf with C

1 Answer

0 votes
#include <stdio.h>

int main() {
    printf("%d:%02d:%04.1f hours\n", 3, 6, 4.2891);
   
    return 0;
}
   
   
   
/*
run:
   
3:06:04.3 hours
   
*/

 



answered Dec 28, 2024 by avibootz

Related questions

...