find函数的使用方法

更新时间:02-04 教程 由 争端 分享

find函数的使用方法?

String类的构造函数和析构函数如下:

a) string s; //生成一个空字符串s

b) string s(str) //拷贝构造函数 生成str的复制品

c) string s(str,stridx) //将字符串str内“始于位置stridx”的部分当作字符串的初值

d) string s(str,stridx,strlen) //将字符串str内“始于stridx且长度顶多strlen”的部分作为字符串的初值

e) string s(cstr) //将C字符串作为s的初值

f) string s(chars,chars_len) //将C字符串前chars_len个字符作为字符串s的初值。

g) string s(num,c) //生成一个字符串,包含num个c字符

h) string s(beg,end) //以区间beg;end(不包含end)内的字符作为字符串s的初值

i) s.~string() //销毁所有字符,释放内存

find()的应用 (rfind() 类似,只是从反向查找)

原型如下:

(1)size_t find (const string& str, size_t pos = 0) const; //查找对象--string类对象

(2)size_t find (const char* s, size_t pos = 0) const; //查找对象--字符串

(3)size_t find (const char* s, size_t pos, size_t n) const; //查找对象--字符串的前n个字符

(4)size_t find (char c, size_t pos = 0) const; //查找对象--字符

声明:关于《find函数的使用方法》以上内容仅供参考,若您的权利被侵害,请联系13825271@qq.com
本文网址:http://www.25820.com/tutorial/14_2292589.html