3 ms·
I don't doubt that can be true - but there are plenty of common operations like concatenating strings or converting between strings/numbers that are a good deal
by wizofaus 4y ago
I don't doubt that can be true - but there are plenty of common operations like concatenating strings or converting between strings/numbers that are a good deal simpler to write and understand in C++ than they are in C. In particular there are far more ways to get them wrong in C!
- uecker 4y agoIf you code them by hand, then yes. If you a library, then it is the same. It is certainly true that the C++ standard library provides more functionality out of the box.
- wizofaus 4y agoAlmost any C library function that deals with strings is going to be more complex to use due to the lack of automatic memory handling, necessary for any use case where the max. size isn't sufficiently well-known at compile time for it to sit on the stack. I'd accept something like "atoi" or "strtol" is pretty simple to use (and hard to get wrong), but hardly win any awards for obviousness. And the less said about the need (or at least strong tendency) to use sscanf for more complex parsing (hexadecimals etc.), the better.
- uecker 4y agoA library can do the memory management for you: string a = string("test"); string b = string(" this"); string n = string_concat(a, b); ...