3 ms·
the 'discarding const' is quite a problem if you try write real code like this.
by silon42 4y ago
the 'discarding const' is quite a problem if you try write real code like this.
- matheusmoreira 4y agoI know. That string literal is likely to be located in a read only page. In real code, I'd have to allocate some memory and copy the text to the new location if I want the resulting structure to be writable. For clarity's sake I omitted these details. This isn't unique to my example though. Traditional C strings have the exact same problem and they do get copied all the time.