I\'m trying to output some numbers in a log file and I want to pad a load of floats via the printf function to produce:
printf
058.0 020.0 038.0 -050.0
follows Erik, but I find
printf("% 6.1f\n", myVar);
also works.
The width specifier is the complete width:
printf("%05.1f\n", myVar); // Total width 5, pad with 0, one digit after .
To get your expected format:
printf("% 06.1f\n", myVar);