3 ms·
> With C++, if you have char*'s (because you don't need to own the memory) If you are using C strings in C++ you are either doing something incredibly low leve
by josefx 4y ago
> With C++, if you have char*'s (because you don't need to own the memory)
If you are using C strings in C++ you are either doing something incredibly low level or don't care about performance at all. C strings require strlen calls or something equivalent for basic operations and you can easily run into code with exploding runtime if you aren't extremely careful.
- saagarjha 4y ago> If you are using C strings in C++ you are either doing something incredibly low level or don't care about performance at all. …or interoperating with C code?
- sseagull 4y agoBut the temporary copy only happens going from const char * to std::string, so the C code would have to be calling C++ code. std::string to const char doesn’t (usually?) require copying.