Dynamic Minimum width with Format / writefln

Adam D. Ruppe destructionator at gmail.com
Wed Oct 3 01:29:04 UTC 2018


On Wednesday, 3 October 2018 at 01:14:24 UTC, Chris Katko wrote:
> I'm not sure how I made this mistake. But it seems to only show 
> up now if I leave .toStringz() with the writefln.

Yeah.

So what's happening here is toStringz returns the C-style char*, 
which printf works well with, but writef doesn't trust it and 
just prints the pointer value instead of trying to traverse it 
looking for a zero terminator (which might not be there).

Just passing a D string will work consistently.

> So maybe I've been staring at code too long tonight and simply 
> missed it?

oh probably, it happens to everyone :)


More information about the Digitalmars-d-learn mailing list