Thread overview
variable width format specifiers
May 24, 2006
Carlos Santander
May 24, 2006
Derek Parnell
May 24, 2006
Carlos Santander
May 24, 2006
(I hope I got the subject right)

How is this C code translated to D using Phobos?

        int l = 8, d = 4;
        double v = 34.289;

        sprintf (buf, "%*.*g", l, d, v);

-- 
Carlos Santander Bernal
May 24, 2006
On Tue, 23 May 2006 21:46:23 -0500, Carlos Santander wrote:

> (I hope I got the subject right)
> 
> How is this C code translated to D using Phobos?
> 
>          int l = 8, d = 4;
>          double v = 34.289;
> 
>          sprintf (buf, "%*.*g", l, d, v);

import std.string;
import std.stdio;

void main()
{
    int l = 8, d = 4;
    double v = 34.289;
    char[] buf;

    buf = std.string.format( "%*.*g", l, d, v);
    writefln("'%s'", buf);
}

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocracy!"
24/05/2006 1:49:41 PM
May 24, 2006
Derek Parnell escribió:
> On Tue, 23 May 2006 21:46:23 -0500, Carlos Santander wrote:
> 
>> (I hope I got the subject right)
>>
>> How is this C code translated to D using Phobos?
>>
>>          int l = 8, d = 4;
>>          double v = 34.289;
>>
>>          sprintf (buf, "%*.*g", l, d, v);
> 
> import std.string;
> import std.stdio;
> 
> void main()
> {
>     int l = 8, d = 4;
>     double v = 34.289;
>     char[] buf;
> 
>     buf = std.string.format( "%*.*g", l, d, v);
>     writefln("'%s'", buf);
> }
> 

I missed that. Thanks!

-- 
Carlos Santander Bernal