-
auto s = "abcd"creatsconst char *not string, so useautowith caution. -
Since a string in C++ is an array of chars, you can operate it like an array. For example, you can use range-based for loop and so on.
-
It is recommended that you use
std::stringin function which are not intended to be interfaces, and you useconst char *as parameters of function that are intended to be interfaces (e.g., compiled as shared library and so on). -
You can use
==to compare whether the content of twostd::stringare the same, but you cannot use==to compare the content ofconst char *.