Printf float with number of trailing zeros in variable
2 answers
This should work for you:
A small sample program for testing:
#include <stdio.h>
int main() {
float f = 4.3234;
int x = 2;
printf("%.*f", x, f);
return 0;
}
For more information see http://www.cplusplus.com/reference/cstdio/printf/
+5
source to share