yes, I forgot one. I also found code that resolves my issue and I get the 
formatting I want (which what I really want is a quantity of lhs digits and a 
qty of rhs digits.


printf("precision=%d, d=%*.*f\n", width, precision, d);  //generates forever 
loop of spaces, program hangs.

#include <cstdio>//stdio.h
int main(void) {
    int lhsNumDigits=9, rhsNumDigits=5, width=lhsNumDigits+rhsNumDigits+1, 
precision=rhsNumDigits;

    //floats
    printf("d=%0*.*f\n", width, precision, 55.292);
    //d=000000055.29200
    printf("d=%*.*f\n", width, precision, 55.292);
    //d=       55.29200

    //strings too.
    printf("d=%*s\n", 5, "abc");
    //d=  abc
    printf("d=%*s\n", 5, "abcdefghi");
    //d=abcdefghi

    return 0;
}


thanks folks. problem resolved.


>________________________________
> From: "[email protected]" <[email protected]>
>To: [email protected] 
>Cc: [email protected]; [email protected] 
>Sent: Saturday, May 10, 2014 3:07 AM
>Subject: Re: [Mingw-w64-public] printf
> 
>
>Jim Michaels <[email protected]> said:
>> 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.
>
>Elementary programming error: for each * in the format, you must supply
>an argument. man 3 printf
>
>Cheers,
>--Sampo
>
>>     return 0;
>> }
>> 
>> 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
>> [email protected]
>> [email protected]
>> http://RenewalComputerServices.com
>> http://JesusnJim.com (my personal site, has software)
>
>
>
>
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to