码迷,mamicode.com
首页 > 其他好文 > 详细

string::find

时间:2019-12-19 19:34:38      阅读:106      评论:0      收藏:0      [点我收藏+]

标签:bottom   weight   npos   eve   ext   style   include   clu   ica   

string (1)
size_t find (const string& str, size_t pos = 0) const noexcept;
c-string (2)
size_t find (const char* s, size_t pos = 0) const;
buffer (3)
size_t find (const char* s, size_t pos, size_type n) const;
character (4)
size_t find (char c, size_t pos = 0) const noexcept;

#include <iostream>
#include <string>

using namespace std;

int main()
{
string s1 = "i love lyy, i hope lyy can be married to me";
string s2 = "lyy";
cout << s1.find(s2) << endl;
cout << s1.find(s2, 50) << endl;
if(s1.find(s2, 50) == string::npos)
cout << "out_of_range" << endl;

const char *s3 = "lyy";
cout << "3: " << s1.find(s3, 8, 3) << endl;
cout << "4: " << s1.find(‘m‘, 6) << endl;
return 0;
}

string::find

标签:bottom   weight   npos   eve   ext   style   include   clu   ica   

原文地址:https://www.cnblogs.com/xpylovely/p/12069314.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!