< C++ > string c_str

来源:互联网 发布:精修图片软件 编辑:程序博客网 时间:2024/05/15 01:00
c_str() 以const char* 类型返回 string 内含的字符串
如果一个函数要求char*参数,可以使用c_str()方法:
string s = "Hello World!";
printf("%s", s.c_str()); //输出 "Hello World!"
原创粉丝点击