您的位置:首页 > 其它

c++ primer笔记之string

2008-07-22 16:57 274 查看
 

string 类提供了一套查找函数都以find 的各种变化形式命名find()是最简单的实例
给出一个字符串它返回匹配子串的第一个字符的索引位置或者返回一个特定的值
string::npos
msdn的解释如下“An unsigned integral value initialized to –1 that indicates either "not found" or "all remaining characters" when a search function fails.”

find_first_not_of()查找第一个不与要搜索字符串的任意字符相匹配的字符例如为找
到第一个非数字字符可以写
string elems( "0123456789" );
string dept_code( "03714p3" );
// returns index to the character 'p'
string::size_type pos = dept_code.find_first_not_of(elems);
find_last_of()查找字符串中的与搜索字符串任意元素相匹配 的最后一个字符
find_last_not_of()查找字符串中的与搜索字符串任
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: