c++中string类成员函数c_str()
来源:互联网 发布:网络受限怎么办 编辑:程序博客网 时间:2024/06/05 02:39
1.string类成员函数c_str()的原型:
const char *c_str()const;//返回一个以null终止的c字符串
2.c_str()函数返回一个指向正规c字符串的指针,内容和string类的本身对象是一样的,通过string类的c_str()函数能够把string对象转换成c中的字符串的样式;
3.操作c_str()函数的返回值时,只能使用c字符串的操作函数,如:strcpy()等函数.因为,string对象可能在使用后被析构函数释放掉,那么你所指向的内容就具有不确定性.
eg:
char * name[20];
string ptr = "tongnono";
strcpy(name,ptr.c_str());//c_str()返回的是一个临时的指针变量,不能对其操作.
- c++中string类成员函数c_str()
- c++中string类成员函数c_str()
- c++中string类成员函数c_str()
- c++中string类成员函数c_str()
- c++中string类成员函数c_str()
- string 类成员函数c_str
- C++中string类对象的成员函数c_str()与C语言中字符串的联系
- c++中string类成员函数c_str()的用法
- c++中string类成员函数c_str()的用法
- string类的成员函数c_str()
- string类成员函数c_str()介绍
- C++string类的c_str()函数
- string类中c_str函数的用法
- string类中c_str函数的用法
- String 类 的c_str()函数
- C string类c_str() 详解
- string中c_str()函数的用法
- C/C++:string.c_str()
- void ArpRequest (void)
- MapReduce 流程详述
- JavaWEB开发-国际化
- iOS开发:iOS网络编程--ASIHTTPRequest框架安装和配置
- experiment : 使用vs2008编译C文件
- c++中string类成员函数c_str()
- Ubuntu安装MongoDB
- 端口号被占用解决方法
- PHP MVC快速开发框架EaglePHP v2.5正式发布
- Fiddler 教程
- 模式识别
- 容器使用经验总结
- 虚函数 纯虚函数
- FME 安装破解及与ArGIS冲突的解决方法