How to use sprintf

Steven Schveighoffer schveiguy at yahoo.com
Mon Apr 25 08:39:28 PDT 2011


On Mon, 25 Apr 2011 11:26:57 -0400, Vladimir Panteleev  
<vladimir at thecybershadow.net> wrote:

> On Mon, 25 Apr 2011 18:21:16 +0300, Robert Clipsham  
> <robert at octarineparrot.com> wrote:
>
>> On 25/04/2011 15:56, Vladimir Panteleev wrote:
>>> On Mon, 25 Apr 2011 17:19:12 +0300, Steven Schveighoffer
>>> <schveiguy at yahoo.com> wrote:
>>>
>>>> The problem the OP has is he is casting buffer to a char *. He should
>>>> just use buffer.ptr.
>>>
>>> Casting a string to char* is exactly the same as using the .ptr
>>> property, as far as generated code is concerned.
>>
>> Not when a string is defined internally as struct { size_t length;  
>> immutable(char)* ptr; }. Casting to char* is a pointer to the start of  
>> the length, not the pointer.
>
> Try it.
>

BTW, that got me curious what the real failure of the original code was,  
and I tried it.  Turns out, it actually runs successfully!

So I can only guess that the OP didn't post his actually failing code.

-Steve


More information about the Digitalmars-d mailing list