使用std::string时,注意的两点
来源:互联网 发布:matlab矩阵的转置 编辑:程序博客网 时间:2024/06/05 18:09
在使用string时有两点需要注意.不然全发生让你莫名其妙的错误,而摸不着头脑
1.给一个string对象赋值时,千万不要赋空指针字符.不然,准叫你崩溃
2.在使用find查找一个子字符串时,如果被查找的字符为空,则返回0的位置,而不是sring::npos
比如:
string strOr("limit");
string strFind; //空的
string::size_type pos = strOr.find(strFind);
或string::size_type pos = strOr.find("");
string strFind; //空的
string::size_type pos = strOr.find(strFind);
或string::size_type pos = strOr.find("");
此时pos等于0,而不是string::npos.以前一直以为是string::npos呢
- 使用std::string时,注意的两点
- 使用std::string::find() 和 std::string::npos需要注意的地方
- std::string 内存管理特别,多线程使用时应注意
- std::string 内存管理特别,多线程使用时应注意
- 使用std::string 通过dll接口传递时,应该注意的问题
- std string 的常用使用
- std:: string 的常用使用
- std string 的常用使用
- std string 的常用使用
- std string 的常用使用
- 使用count()要注意的两点
- 使用count()要注意的两点
- 使用execvp()函数需要注意的两点
- 使用execvp()函数需要注意的两点
- switch语句使用要注意的两点
- 使用std::sort需要注意的问题
- 数据库编程时需要注意的两点!
- 循环时两点注意
- J2EE入门视频教程第四讲——数据库技术简介及环境配置
- [记录]升级到yake0.7....
- = =在我们公司所谓的迭代式开发....
- 昭东兄,一路走好
- 关于connect需要注意的一点
- 使用std::string时,注意的两点
- Remain 用法
- 如何成为一名合格的部门经理
- 系动词
- 英语系动词用法小结
- test
- 常见图片格式
- [转贴]趁“雪”打劫:从盒饭居然涨至一份50元谈起
- ajax登陆实例,运用ajaxPro框架(转载)