C++ string::find_first_of
来源:互联网 发布:mac 快捷键 箭头 编辑:程序博客网 时间:2024/06/03 04:40
语法:
size_type find_first_of( const basic_string &str, size_type index = 0 );
size_type find_first_of( const char *str, size_type index = 0 );
size_type find_first_of( const char *str, size_type index, size_type num );
size_type find_first_of( char ch, size_type index = 0 );
find_first_of()函数:
查找在字符串中第一个与str中的某个字符匹配的字符,返回它的位置。搜索从index开始,如果没找到就返回string::npos
查找在字符串中第一个与str中的某个字符匹配的字符,返回它的位置。搜索从index开始,最多搜索num个字符。如果没找到就返回string::npos,
查找在字符串中第一个与ch匹配的字符,返回它的位置。搜索从index开始。
size_type find_first_of( const basic_string &str, size_type index = 0 );
size_type find_first_of( const char *str, size_type index = 0 );
size_type find_first_of( const char *str, size_type index, size_type num );
size_type find_first_of( char ch, size_type index = 0 );
find_first_of()函数:
查找在字符串中第一个与str中的某个字符匹配的字符,返回它的位置。搜索从index开始,如果没找到就返回string::npos
查找在字符串中第一个与str中的某个字符匹配的字符,返回它的位置。搜索从index开始,最多搜索num个字符。如果没找到就返回string::npos,
查找在字符串中第一个与ch匹配的字符,返回它的位置。搜索从index开始。
Example
// string::find_first_of#include <iostream>#include <string>using namespace std;int main (){ string str ("Replace the vowels in this sentence by asterisks."); size_t found; found=str.find_first_of("aeiou"); while (found!=string::npos) { str[found]='*'; found=str.find_first_of("aeiou",found+1); } cout << str << endl; return 0;}
R*pl*c* th* v*w*ls *n th*s s*nt*nc* by *st*r*sks.经过测试,成功运行。注意:单个字符时单引号,多个字符双引号。字符下标从零开始。
0 0
- string find_first_of
- C++--string--find_first_of() 和 find_last_of(),find()与npos
- C++ string::find_first_of
- C++ string::find_first_of
- string c++详解 find_first_not_of() find_first_of()
- string 中的 find()、 find_first_of()、find_first_not_of()
- string 搜索功能 find find_first_of
- C++string中的查找函数find与find_first_of函数的区别
- find_first_of
- find_first_of
- find_first_of
- find_first_of
- find_first_of
- find_first_of
- string中的find(),find_first_of(),find_first_not_of()之间区别
- string 中find_first_of()函数用法例题
- string的find和find_first_of的区别
- C++ string类:find()和find_first_of()
- 程序员的成长之路
- mac下修改调试安卓apk的默认签名文件
- 类方法实例方法,类变量实例变量的比较
- 黑马程序员--局部变量和成员变量
- Java线程状态图
- C++ string::find_first_of
- 回文距离
- [叁]Pomelo游戏服务器编程分享 之 服务器结构与配置分析
- 2014年多校联赛总结
- 快速入门C++ 04(传值、传址传引用)
- 黑马程序员--线程总结
- 给tcpdump加点颜色看看
- Box2D C++ 物体的安全删除
- win32 剪切板操作