Most std::string implementations probably save the actual string as a C string anyway, so the c_str function is just a built-in function that returns a pointer. Therefore, as a rule, I would say that the correct way is std::string .
Of course, if the string should be changed by the function you are calling, you cannot use the std::string approach. Instead, you will need to make a copy in your own buffer before calling the function, in which case using arrays can be a way.
source share