How to write printf(...) like function

Chris Sauls ibisbasenji at gmail.com
Wed Mar 8 14:41:53 PST 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
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: coprint.d
Url: http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20060308/7fb7240c/attachment.ksh 


More information about the Digitalmars-d-learn mailing list