string c_str() vs. data()

The documentation is correct. Use c_str() if you want a null terminated string. If the implementers happend to implement data() in terms of c_str() you don’t have to worry, still use data() if you don’t need the string to be null terminated, in some implementation it may turn out to perform better than c_str(). strings … Read more