digitalmars.D - std.stream.vprintf
- ben (9/9) Jun 13 2005 How can I make use of std.stream.vprintf. This if obviously wrong, beca...
- Derek Parnell (12/24) Jun 13 2005 import std.stdarg;
- Derek Parnell (6/28) Jun 13 2005 Nope, this doesn't work either. Sorry, but maybe its a lead.
- Derek Parnell (25/51) Jun 13 2005 Here is one that does work ...
- Vathix (4/14) Jun 13 2005 Not an answer but it would be nice if there was vwritef().
- Derek Parnell (12/31) Jun 13 2005 Yes, I was just thinking the same thing.
- Ben Hinkle (4/14) Jun 29 2005 note vprintf is not static so one must supply an instance of a stream as...
How can I make use of std.stream.vprintf. This if obviously wrong, because it won't compile. import std.stream; import std.c.process; void die(char[] fmt, ...){ std.stream.vprintf(fmt, _argptr); exit(1); } Any help is much appreciated.
Jun 13 2005
On Tue, 14 Jun 2005 05:20:46 +0000 (UTC), ben wrote:How can I make use of std.stream.vprintf. This if obviously wrong, because it won't compile. import std.stream; import std.c.process; void die(char[] fmt, ...){ std.stream.vprintf(fmt, _argptr); exit(1); } Any help is much appreciated.import std.stdarg; void die(char[] fmt, ...) { va_list ap; ap = cast(va_list) &fmt; ap += fmt.sizeof; std.stream.vprintf(fmt, ap); } -- Derek Melbourne, Australia 14/06/2005 3:29:15 PM
Jun 13 2005
On Tue, 14 Jun 2005 15:31:34 +1000, Derek Parnell wrote:On Tue, 14 Jun 2005 05:20:46 +0000 (UTC), ben wrote:Nope, this doesn't work either. Sorry, but maybe its a lead. -- Derek Melbourne, Australia 14/06/2005 3:47:05 PMHow can I make use of std.stream.vprintf. This if obviously wrong, because it won't compile. import std.stream; import std.c.process; void die(char[] fmt, ...){ std.stream.vprintf(fmt, _argptr); exit(1); } Any help is much appreciated.import std.stdarg; void die(char[] fmt, ...) { va_list ap; ap = cast(va_list) &fmt; ap += fmt.sizeof; std.stream.vprintf(fmt, ap); }
Jun 13 2005
On Tue, 14 Jun 2005 15:47:48 +1000, Derek Parnell wrote:On Tue, 14 Jun 2005 15:31:34 +1000, Derek Parnell wrote:Here is one that does work ... <code> import std.stdarg; import std.stream; BufferedFile f; void die(char[] fmt, ...) { va_list ap; ap = cast(va_list) &fmt; ap += fmt.sizeof; f.vprintf(fmt, ap); } void main() { f = new BufferedFile("c:\\temp\\test.txt", FileMode.OutNew); // NOTE **** The usage of 'C' style string format code '%.*s' die("Code: %d is '%.*s'\n", 12, "test value"); f.close(); } </code> -- Derek Melbourne, Australia 14/06/2005 4:04:58 PMOn Tue, 14 Jun 2005 05:20:46 +0000 (UTC), ben wrote:Nope, this doesn't work either. Sorry, but maybe its a lead.How can I make use of std.stream.vprintf. This if obviously wrong, because it won't compile. import std.stream; import std.c.process; void die(char[] fmt, ...){ std.stream.vprintf(fmt, _argptr); exit(1); } Any help is much appreciated.import std.stdarg; void die(char[] fmt, ...) { va_list ap; ap = cast(va_list) &fmt; ap += fmt.sizeof; std.stream.vprintf(fmt, ap); }
Jun 13 2005
On Tue, 14 Jun 2005 01:20:46 -0400, ben <ben_member pathlink.com> wrote:How can I make use of std.stream.vprintf. This if obviously wrong, because it won't compile. import std.stream; import std.c.process; void die(char[] fmt, ...){ std.stream.vprintf(fmt, _argptr); exit(1); } Any help is much appreciated.Not an answer but it would be nice if there was vwritef(). While looking through the docs I noticed writef() returns Stream when it should probably return OutputStream.
Jun 13 2005
On Tue, 14 Jun 2005 02:25:23 -0400, Vathix wrote:On Tue, 14 Jun 2005 01:20:46 -0400, ben <ben_member pathlink.com> wrote:Yes, I was just thinking the same thing. And I just slapped myself because a simpler solution is just ... BufferedFile f; void die(char[] fmt, ...) { f.vprintf(fmt, _argptr); } -- Derek Melbourne, Australia 14/06/2005 4:28:26 PMHow can I make use of std.stream.vprintf. This if obviously wrong, because it won't compile. import std.stream; import std.c.process; void die(char[] fmt, ...){ std.stream.vprintf(fmt, _argptr); exit(1); } Any help is much appreciated.Not an answer but it would be nice if there was vwritef().
Jun 13 2005
"ben" <ben_member pathlink.com> wrote in message news:d8lpfe$6ho$1 digitaldaemon.com...How can I make use of std.stream.vprintf. This if obviously wrong, because it won't compile. import std.stream; import std.c.process; void die(char[] fmt, ...){ std.stream.vprintf(fmt, _argptr); exit(1); } Any help is much appreciated.note vprintf is not static so one must supply an instance of a stream as Derek's post suggests.
Jun 29 2005