首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

find跟find_first_of的区别

2012-09-24 
find和find_first_of的区别find函数的声明:size_t find ( const string& str, size_t pos 0 ) constsiz

find和find_first_of的区别
find函数的声明:
size_t find ( const string& str, size_t pos = 0 ) const;
size_t find ( const char* s, size_t pos, size_t n ) const;
size_t find ( const char* s, size_t pos = 0 ) const;
size_t find ( char c, size_t pos = 0 ) const;

find_first_of函数的声明:
size_t find_first_of ( const string& str, size_t pos = 0 ) const;
size_t find_first_of ( const char* s, size_t pos, size_t n ) const;
size_t find_first_of ( const char* s, size_t pos = 0 ) const;
size_t find_first_of ( char c, size_t pos = 0 ) const;

find函数寻找完整匹配,find_first_of函数寻找任一匹配。
示例:

string line = "what_a_good_day_!";line.find("_!");  //return 15line.find_first_of("_!");  //return 4

热点排行