3 ms·
I 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
by matheusmoreira 4y ago
I 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.