const pointers C vs. D

Johann Lermer jlermer at elvin.eu
Tue Feb 4 10:06:03 UTC 2020


Hi,

I'm just wondering about defining const pointers and if there's a 
difference in C and D.

in C, this works:

const char* text = "Hello";
text = "world";

but in D it doesn't, because the char* is const. Ff I would like 
tho have the same behaviour in D as in C, I need to write:

const (char)* text = "Hello";
text = "world";

In C, this would not be valid. So the question for me now is: is 
const char* in D different from C?



More information about the Digitalmars-d-learn mailing list