C to D conversion for function

Timon Gehr timon.gehr at gmx.ch
Mon Apr 29 05:22:39 PDT 2013


On 04/29/2013 02:17 PM, 1100110 wrote:
> ...
> What is the difference between const(char)*, and const(char*)?  I have
> seen them used pretty much interchangeably...
>
> Are they? Somehow I don't think they are.
>

Variables of type const(char)* can be mutated, while const(char*) cannot be.

void main(){
     const(char)* a = "123".ptr;
     *a = 2;        // error
     a = "456".ptr; // ok
     const(char*) b = "123".ptr;
     *b = 2;        // error
     b = "456".ptr; // error
}


More information about the Digitalmars-d-learn mailing list