As we know member function data() defined by string won't append a NULL character at the end of string. But I found it still appends a NULL character at the end of string. Please check the following code, Code: int main() { string s = "Mike"; char* q = const_cast<char*>(s.data()); while(*q) { q++; } return 0; } Debug this piece of code, you will find out there is a NULL character at the end of string. Why?