Thread overview
How to write printf(...) like function
Mar 08, 2006
Cris
Mar 08, 2006
Chris Sauls
Mar 09, 2006
Cris
March 08, 2006
    Where is what I'm trying to do is to make a print function that outputs both to a console and to a file but I have get a std.format runtime error. Any ideas how to do it?


    void printTo(...)
    {
        char[] string;

        void putc(dchar c)
        {
            string ~= c;
        }

        std.format.doFormat(&putc, _arguments, _argptr);

            printf(string ~= "\0"); //  std.c.stdio
            file.printf(string);
    }
March 08, 2006
Cris wrote:
>     Where is what I'm trying to do is to make a print function that
> outputs both to a console and to a file but I have get a std.format
> runtime error. Any ideas how to do it?
> 
> 
>     void printTo(...)
>     {
>         char[] string;
> 
>         void putc(dchar c)
>         {
>             string ~= c;
>         }
> 
>         std.format.doFormat(&putc, _arguments, _argptr);
> 
>             printf(string ~= "\0"); //  std.c.stdio
>             file.printf(string);
>     }

The attached file is my own test and partial rewrite of your function, which essentially works.

-- Chris Nicholson-Sauls


March 09, 2006
Thank you for the help! Your code works now.

Was the problem the standard C printf?

> 
> The attached file is my own test and partial rewrite of your function, which essentially works.
> 
> -- Chris Nicholson-Sauls
>