www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Something other than printf/writef?

reply Dawid =?ISO-8859-2?Q?Ci=EA=BFarkiewicz?= <arael fov.pl> writes:
I hate printf. It's type usafe, it likes to crash etc., etc.
I wish I could just:

char[] s;
int i;

file.scan(i).scan(s);
file.write("bla ").write(i);

and same with stdio. Can I?
-- 
Dawid Ciężarkiewicz | arael
jid: arael fov.pl
Oct 30 2004
next sibling parent reply Lars Ivar Igesund <larsivar igesund.net> writes:
You mention writef in your subject. D's writef (and writefln) is a 
typesafe version of printf. You find them in std.stdio.

Lars Ivar Igesund

Dawid Ciężarkiewicz wrote:
 I hate printf. It's type usafe, it likes to crash etc., etc.
 I wish I could just:
 
 char[] s;
 int i;
 
 file.scan(i).scan(s);
 file.write("bla ").write(i);
 
 and same with stdio. Can I?
Oct 30 2004
parent reply Dawid =?ISO-8859-2?Q?Ci=EA=BFarkiewicz?= <arael fov.pl> writes:
Lars Ivar Igesund wrote:

 You mention writef in your subject. D's writef (and writefln) is a
 typesafe version of printf. You find them in std.stdio.
Right. But I still got to use those "%s" etc. things ... -- Dawid Ciężarkiewicz | arael jid: arael fov.pl
Oct 30 2004
parent reply h3r3tic <foo bar.baz> writes:
Dawid Ciężarkiewicz wrote:
 Lars Ivar Igesund wrote:
 
 
You mention writef in your subject. D's writef (and writefln) is a
typesafe version of printf. You find them in std.stdio.
Right. But I still got to use those "%s" etc. things ...
Nope, you don't have to. writefln("foo ", 345, " bar ", 345.34, " baz"); you can use them though if you want formatting, like: writefln("round(2): %2.2f", 345.34534);
Oct 30 2004
parent "Ivan Senji" <ivan.senji public.srce.hr> writes:
"h3r3tic" <foo bar.baz> wrote in message
news:cm0iai$2ca$1 digitaldaemon.com...
 Dawid Ciężarkiewicz wrote:
 Lars Ivar Igesund wrote:


You mention writef in your subject. D's writef (and writefln) is a
typesafe version of printf. You find them in std.stdio.
Right. But I still got to use those "%s" etc. things ...
Nope, you don't have to.
Have you tried: writefln("%"); i can't try it now but i remember it used to not work. Btw (this is reply to Lars Ivar Igesund): writef is runtime type safe, it cheks all the types at runtime, while something like what David (and i) would like does compile time type checking.
 writefln("foo ", 345, " bar ", 345.34, " baz");

 you can use them though if you want formatting, like:

 writefln("round(2): %2.2f", 345.34534);
Oct 30 2004
prev sibling parent reply teqDruid <me teqdruid.com> writes:
Mango's got stuff like this.

On Sat, 30 Oct 2004 14:35:13 +0200, Dawid wrote:

 I hate printf. It's type usafe, it likes to crash etc., etc.
 I wish I could just:
 
 char[] s;
 int i;
 
 file.scan(i).scan(s);
 file.write("bla ").write(i);
 
 and same with stdio. Can I?
Oct 30 2004
parent Dawid =?ISO-8859-2?Q?Ci=EA=BFarkiewicz?= <arael fov.pl> writes:
teqDruid wrote:
 Mango's got stuff like this.
I'll try it - thanks, -- Dawid Ciężarkiewicz | arael jid: arael fov.pl
Oct 31 2004