digitalmars.D.learn - How to write printf(...) like function
- Cris <central_p hotmail.com> Mar 08 2006
- Chris Sauls <ibisbasenji gmail.com> Mar 08 2006
- Cris <central_p hotmail.com> Mar 09 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);
}
Mar 08 2006
Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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
Mar 08 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
Mar 09 2006








Cris <central_p hotmail.com>