3 ms·
The main issue, which the article covers, is that there's really two different operations you want with copying C strings. Do you want to copy and truncate, or
by pton_xd 2y ago
The main issue, which the article covers, is that there's really two different operations you want with copying C strings.
Do you want to copy and truncate, or just copy?
Within that, do you want to manage your own allocation, or do you want that abstracted?
There's too many decision points and tradeoffs to just neatly hide behind a single "one true function" for copying C strings.
- bruce343434 2y agoIs it bad that for all application uses, I reach for `asprintf`? As well as reaching for the %ms format for scanf for reading input. For buffers, I use memcpy and length tracking. Any other approach seems like unnecessary headache. Or maybe modern hardware has spoiled me?