Re: const pointers C vs. D

2020-02-06 Thread Johann Lermer via Digitalmars-d-learn
On Tuesday, 4 February 2020 at 10:17:39 UTC, Dennis wrote: C++ has a const system that is closer to D's than any other language, but it still has huge differences: Thanks, that clears it up a bit!

Re: const pointers C vs. D

2020-02-04 Thread Dennis via Digitalmars-d-learn
On Tuesday, 4 February 2020 at 10:06:03 UTC, Johann Lermer wrote: In C, this would not be valid. So the question for me now is: is const char* in D different from C? Yes, const char* in D reads as const(char*), so it is a char* that cannot be modified. This is similar to the C code: char

const pointers C vs. D

2020-02-04 Thread Johann Lermer via Digitalmars-d-learn
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