std :: string :: c_str和std :: string :: data有什么区别? [英] What's the difference between std::string::c_str and std::string::data?
本文介绍了std :: string :: c_str和std :: string :: data有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我为什么要通过 std::string::c_str()
?当然,这里有一些解决标准的方法...
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...
推荐答案
c_str()保证NUL终止. data()没有.
c_str() guarantees NUL termination. data() does not.
这篇关于std :: string :: c_str和std :: string :: data有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文