(C++) const char* to char* - how?

Started by
10 comments, last by Enigma 15 years, 11 months ago
Quote:Original post by DevFred
Hm, are we saying the same thing?

Quote:Original post by DevFred
const char* p = "Hello World!"; // unmodifiable string literal

Quote:Original post by SiCrane
Which means that a string literal is not necessarily unmodifiable.

No. We aren't saying the same thing.
Advertisement
SiCrane, I'm afraid I'm not clear what you are saying. Writing to a string literal is explicitly undefined behaviour (2.13.4.2). If you were merely pointing out that, depending on compiler, it might work, well... yes. The same way that double deleting a pointer might "work". Admittedly there is a distiction between the two, but not so much of one that I would go so far as to call string literals sometimes "modifiable".

Σnigma

This topic is closed to new replies.

Advertisement