Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我无法理解从 string.c_str() 返回的 char * 是否指向同一个缓冲区(并且不进行任何复制)它是如何以空值终止的?该函数是否在字符串末尾添加空终止符?如果缓冲区没有任何额外的字节来存储它会发生什么?
谢谢。
从 C++11 开始,字符串在内部以空值结尾,并且两者都c_str()返回data()相同的东西。
c_str()
data()