Idea: Introduce zero-terminated string specifier

Piotr Szturmaj bncrbme at jadamspam.pl
Mon Oct 1 02:42:32 PDT 2012


Jakob Ovrum wrote:
> On Monday, 1 October 2012 at 09:17:52 UTC, Piotr Szturmaj wrote:
>> Adam D. Ruppe wrote:
>>> On Saturday, 29 September 2012 at 02:11:12 UTC, Alex Rønne Petersen
>>> wrote:
>>> 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.
>
> It's not safe to assume that pointers to characters are generally null
> terminated.

Yes, but programmer should know what he's passing anyway.


More information about the Digitalmars-d mailing list