Idea: Introduce zero-terminated string specifier

Piotr Szturmaj bncrbme at jadamspam.pl
Mon Oct 1 02:18:16 PDT 2012


Adam D. Ruppe wrote:
> On Saturday, 29 September 2012 at 02:11:12 UTC, Alex Rønne Petersen wrote:
>> While the idea is reasonable, the problem then becomes that if you
>> accidentally pass a non-zero terminated char* to %sz, all hell breaks
>> loose just like with printf.
>
> That's the same risk with to!string(), yes? We aren't really losing
> anything by adding it.
>
> Also this reminds me of the utter uselessness of the current behavior of
> "%s" and a pointer - it prints the address.

Why not specialize current "%s" for character pointer types so it will 
print null terminated strings? It's always possible to cast to void* to 
print an address.


More information about the Digitalmars-d mailing list