De-Referencing A Pointer

Regan Heath regan at netwin.co.nz
Tue Mar 21 00:33:40 PST 2006


On Tue, 21 Mar 2006 20:30:46 +1200, Regan Heath <regan at netwin.co.nz> wrote:
> On Tue, 21 Mar 2006 09:00:15 +0100, Oskar Linde  
> <oskar.lindeREM at OVEgmail.com> wrote:
>> Rory Starkweather skrev:
>>> Still working on a VB to D DLL interface. I want to pass a string to a  
>>> D
>>> function. The only way I have been able to do it without errors is  
>>> ByRef on the
>>> VB end, as expected, to a char* on the D end. However, I want to use  
>>> the 'find'
>>> function on the string. 'find' requires a char[] and a dchar as  
>>> inputs. I
>>> I haven't been able to figure out how to de-reference the pointer for  
>>> the char[]
>>> and I don't know how to produce a dchar.
>>
>> a char* cStr is converted to char[] by
>>
>> cStr[0..std.c.string.strlen(cStr)]
>>
>> or
>>
>> std.string.toString(cStr)
>
> and you can get a dchar with std.utf.toUTF32().

Oops, I should read the whole post before replying. Any character literal  
will be accepted as a dchar, eg.

void foo(dchar c) {}
void main()
{
	foo('a');
}

so you'll probably have no trouble there. :)

Regan



More information about the Digitalmars-d-learn mailing list