大家讲道理2017-04-17 13:46:57
Picture above
The string type treats '0' as an ordinary character, and the length is increased by one. It can be seen that '0' is not the end character and does not contain special functions. There is no need to add '0' at the end of the string
There is no string type in C language, but a character array is used instead. Generally, character arrays can be of uncertain length.
char * string = "ABCD". How does the compiler know the end of the string? It usually adds '0' at the end. '
高洛峰2017-04-17 13:46:57
std::string
and C-style string in C++ are two different strings. The former is a class defined in the standard library, and the latter is an alias for a character array.
C-style string: usually ends with