Hi,
I think this explains what I'm trying to do:
I don't wish to hard code the way of formatting a float, but what I've got doesn't work, any solutions to this???Code:for(i=0;i<5;i++) { printf("float j=%%d.%df\n",i,i,j); }
Hi,
I think this explains what I'm trying to do:
I don't wish to hard code the way of formatting a float, but what I've got doesn't work, any solutions to this???Code:for(i=0;i<5;i++) { printf("float j=%%d.%df\n",i,i,j); }
what is it you want it to do?
what are i j?
You mean something like...:
?Code:#include <stdio.h> int main(void) { int i; for(i = 0;i < 5;++i) printf("%*.*f\n", i, i, 1.5f); return 0; }
My output:
Code:itsme@dreams:~/C$ ./varformat 2 1.5 1.50 1.500 1.5000 itsme@dreams:~/C$
If you understand what you're doing, you're not learning anything.
That's what I'm trying to do, thanks a lot.