Hi Jim!
On Fri, May 9, 2014 at 5:29 PM, Jim Michaels <[email protected]> wrote:
> I could not find a good example on this because examples in books are scarce
> as hen's teeth. search engines ignore the * character and maybe even
> interpret it like a wildcard. :-/ so examples on the web are out.
>
> #include <stdio.h>
> int main(void) {
> double d=1234567890.123456789;
> int width=7,precision=3;//tried 3 and 9
> printf("width=%d, precision=%d, d=%*.*f\n", width, precision, d);
> //generates forever loop of spaces, program hangs.
> return 0;
> }
I think that you have too few arguments to your printf call.
I don't actually know what "%*.*f" does, but I assume it uses printf
arguments to specify the actual format. But (according to my
assumption) "width=%d, precision=%d" has already used up the
arguments that "%*.*f" is expecting.
When I change the line
printf("width=%d, precision=%d, d=%*.*f\n", width, precision, d);
to
printf("width=%d, precision=%d, d=%*.*f\n", width, precision,
width, precision, d);
the program works as I would expect, printing out
width=7, precision=3, d=1234567890.123
> I need to use this. but it seems broken. it just locks up generating spaces
> no matter what I put in for numbers. I don't think that's right.
>
> Jim Michaels
> ...
Good luck.
K. Frank
------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
• 3 signs your SCM is hindering your productivity
• Requirements for releasing software faster
• Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public