need help
Deewiant
deewiant.doesnotlike.spam at gmail.com
Tue Apr 25 06:51:36 PDT 2006
Thomas Kuehne wrote:
> That's usually not a good idea(unchecked format strings...)
Huh? In what kind of situation are the following two not equivalent?
writef("%s", s);
writef(s);
Regardless of the type of s, these surely work the same way, right?
Some test code to argue my point:
--
import std.stdio;
template func(TYPE) { void func(TYPE s) {
writef("'", s, "'");
writef(" and ");
writef("'%s'", s);
writefln();
}}
class Foo {
char[] toString() { return "fooclass"; }
}
void main() {
func("asdf");
func(1234);
func(true);
func('n');
func(0.1234);
func(new Foo());
}
--
In func's output, what's on the left side of the "and" is the same as on the
right, in all six cases.
More information about the Digitalmars-d-learn
mailing list