STL 关于find()
来源:互联网 发布:淘宝分享有赏红包规则 编辑:程序博客网 时间:2024/06/01 09:20
用find()可以,?STL的string提供七种参数形式的find(),如果你可以确定你要查找的字符串靠后或者同时有多个子字符串符合,应该使用rfind()系列或者find_last_of()系列函数来查找,STL的string提供了100个以上的操作函数,五个find()函数原型及简单说明:
(1)size_type string::find(char c) const;
(2)size_type string::find(char c,size_type idx) const;
(3)size_type string::find(const string& str) const;
(4)size_type string::find(const string& str,size_type idx) const;
(5)size_type string::find(const char* cstr) const;
(6)size_type string::find(const char* cstr,size_type idx) const;
(7)size_type string::find(const char* cstr,size_type idx,size_type chars_len) const;
说明:
1>.以上函数如果查找失败返回string::npos,如果成功:
函数(1)返回从头开始的第一个字符所在位置
函数(2)返回从idx开始的第一个字符所在位置
函数(3)返回从头开始的第一个子字符串所在位置
函数(4)返回从idx开始的第一个子字符串所在位置
函数(5)返回从头开始的与char*串相等的第一个子串所在位置
函数(6)返回从idx开始的与char*串相等的第一个子串所在位置
函数(7)返回从idx开始的与char*串前chars_len个字符相等的第一个子串所在位置
(1)size_type string::find(char c) const;
(2)size_type string::find(char c,size_type idx) const;
(3)size_type string::find(const string& str) const;
(4)size_type string::find(const string& str,size_type idx) const;
(5)size_type string::find(const char* cstr) const;
(6)size_type string::find(const char* cstr,size_type idx) const;
(7)size_type string::find(const char* cstr,size_type idx,size_type chars_len) const;
说明:
1>.以上函数如果查找失败返回string::npos,如果成功:
函数(1)返回从头开始的第一个字符所在位置
函数(2)返回从idx开始的第一个字符所在位置
函数(3)返回从头开始的第一个子字符串所在位置
函数(4)返回从idx开始的第一个子字符串所在位置
函数(5)返回从头开始的与char*串相等的第一个子串所在位置
函数(6)返回从idx开始的与char*串相等的第一个子串所在位置
函数(7)返回从idx开始的与char*串前chars_len个字符相等的第一个子串所在位置
string str;std:size_type idx = st.find("c");if( std::string::npos != idx ){//查找成功,加入处理步骤}else{//没有找到时的处理}
- STL 关于find()
- 关于stl的find系列
- STL find()
- STL--find()
- STL algorithm find
- STL 之 find find_if
- STL find函数
- STL中的find函数
- stl std::find使用
- STL中的find函数
- 【STL】find的用法
- STL之find
- stl find和find_if
- 【STL】find示例
- STL map: [] 还是find
- STL算法:find、fill
- STL find 算法
- STL 之find & find_if
- GLIB 安装手记
- Proxy源代码分析--谈谈如何学习linux网络编程
- svn的一些用法
- vc 调试信息
- C现代设计前六章
- STL 关于find()
- JAVA 中退出程序的方法
- Desire S system update error
- 删除程序自身
- JAVA 关闭窗口的设置 DISPOSE_ON_CLOSE和EXIT_ON_CLOSE 的区别
- Windows Service
- java 基础总结(个人网络存储)
- [C#]用户名&&密码
- flex radiobutton checkbutton combox color flex 教程 flex培训 flex源码 flex实例