digitalmars.D - std.stream.vprintf
- ben <ben_member pathlink.com> Jun 13 2005
- Derek Parnell <derek psych.ward> Jun 13 2005
- Derek Parnell <derek psych.ward> Jun 13 2005
- Derek Parnell <derek psych.ward> Jun 13 2005
- Vathix <vathix dprogramming.com> Jun 13 2005
- Derek Parnell <derek psych.ward> Jun 13 2005
- "Ben Hinkle" <ben.hinkle gmail.com> Jun 29 2005
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: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); }
Nope, this doesn't work either. Sorry, but maybe its a lead. -- Derek Melbourne, Australia 14/06/2005 3:47:05 PM
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: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); }
Nope, this doesn't work either. Sorry, but maybe its a lead.
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 PM
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: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().
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 PM
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









Derek Parnell <derek psych.ward> 