Thread overview | |||||
---|---|---|---|---|---|
|
March 08, 2006 How to write printf(...) like function | ||||
---|---|---|---|---|
| ||||
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 Re: How to write printf(...) like function | ||||
---|---|---|---|---|
| ||||
Posted in reply to Cris Attachments: | 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 Re: How to write printf(...) like function | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris Sauls | 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
>
|
Copyright © 1999-2021 by the D Language Foundation