% format strings

Grant Edwards grante at visi.com
Mon Aug 23 23:56:03 EDT 2004


On 2004-08-24, ziller <ziller at gmail.com> wrote:

> I meant to say how does it translate the *.  Python lets you use a
> variable to specify the length of precision.
>
> int f_length = 5;
> float fl = 3.5
> printf("%.*f", f_length, fl);
>
> doesn't compile.

Of course not.  It's not valid C.  The following compiles just
fine:

#include <stdio.h>

int f_length = 5;
float fl = 3.5;

void foo(void)
{
  printf("%.*f",f_length, fl);
}

Not sure why you're asking C questions in c.l.p...



-- 
Grant Edwards                   grante             Yow!  Excuse me, but didn't
                                  at               I tell you there's NO HOPE
                               visi.com            for the survival of OFFSET
                                                   PRINTING?



More information about the Python-list mailing list