Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between std::string::c_str and std::string::data? [duplicate]

Why would I ever want to call std::string::data() over std::string::c_str()? Surely there is some method to the standard's madness here...

like image 361
fbrereto Avatar asked Oct 07 '09 21:10

fbrereto


1 Answers

c_str() guarantees NUL termination. data() does not.

like image 114
Jerry Coffin Avatar answered Sep 29 '22 10:09

Jerry Coffin