sac*_*hin 3 c++ stdstring c-str
谁能告诉我C/C++中c_str()函数的用途是什么?在哪种情况下有必要使用它?
And*_*rsK 6
当您想要将字符串与C函数一起使用时
string s = "hello"; printf( "your string:%s", s.c_str() );
Bas*_*tch 5
这是 C++ 的东西,而不是 C 的东西。
c_str(来自)的常见用途std::string是将 C++ 转换std::string为const char*C 字符串,这是许多低级 C 函数(例如 Posix 系统调用stat等)所需要的。
std::string
const char*
stat
归档时间:
14 年,3 月 前
查看次数:
9614 次
最近记录: