The more interesting question

Alex Rønne Petersen alex at lycus.org
Wed May 16 14:06:41 PDT 2012


On 16-05-2012 22:42, Steven Schveighoffer wrote:
> On Wed, 16 May 2012 16:19:36 -0400, Alex Rønne Petersen <alex at lycus.org>
> wrote:
>
>> Theoretically, yes, practically, not really.
>>
>> void myLog(string msg)
>> {
>> printf(msg);
>> }
>
> Wait, this should be an error. You need toStringz there.
>
> -Steve

Sorry, I meant:

void myLog(string msg)
{
     printf(msg.ptr);
}

(Which works as expected because string literals are null-terminated. 
This is also how things work when you pass a string literal to a 
const(char)* value; it just does "literal".ptr.)

-- 
Alex Rønne Petersen
alex at lycus.org
http://lycus.org


More information about the Digitalmars-d mailing list