久久机这里只有精品,国产69精品一区二区亚洲孕妇,91精品国产综合久久婷婷香蕉,午夜久久久久久电影

最新活動:電腦PC端+手機端+微網站+自適應網頁多模板選擇-建站388元起價!!!
當前位置:主頁 > 網站建設 > 深入C++ string.find()函數的用法總結建站知識

深入C++ string.find()函數的用法總結建站知識

時間:2023-05-24 08:05:24 閱讀: 文章分類: 網站建設 作者: 網站編輯員

導讀:1建站知識本篇文章是對C++中string.find()函數的用法進行了詳細的總結與分析,需要的朋友參考下網站建設企業網站建設。

網站建設企業網站建設#include <string>#include <iostream>using namespace std; void main(){

復制代碼 代碼如下:

////find函數返回類型 size_typestring s("1a2b3c4d5e6f7g8h9i1a2b3c4d5e6f7g8ha9i");string flag;string::size_type position;//find 函數 返回jk 在s 中的下標位置 position = s.find("jkseo網站優化"); if (position != s.npos) //如果沒找到,返回一個特別的標志c++中用npos表示,我這里npos取值是4294967295, { cout << "position is : " << position << endl; } else { cout << "Not found the flag" + flag; }

復制代碼 代碼如下:

//find 函數 返回flag 中任意字符 在s 中第一次出現的下標位置 flag = "c"; position = s.find_first_of(flag); cout << "s.find_first_of(flag) is : " << position << endl;

復制代碼 代碼如下:

//從字符串s 下標5開始,查找字符串b ,返回b 在s 中的下標 position=s.find("b",5); cout<<"s.find(b,5) is : "<<position<<endl;

復制代碼 代碼如下:

//查找s 中flag 出現的所有位置。 flag="a"; position=0; int i=1; while((position=s.find_first_of(flag,position))!=string::npos) { //position=s.find_first_of(flag,position); cout<<"position "<<i<<" : "<<position<<endl; position++; i++; }

復制代碼 代碼如下:

//查找flag 中與s 第一個不匹配的位置 flag="acb12389efgxyz789"; position=flag.find_fir建設網站公司st_not_of (s); cout<<"flag.find_first_not_of (s) :"<<position<<endl;

復制代碼 代碼如下:

//反向查找,flag 在s 中最后出現的位置 flag="3"; position=s.rfind (flag); cout<<"s.rfind (flag) :"<<position<<endl;}

說明:1.如果string sub = ”abc“;string s = ”cdeabcigld“;s.find(sub) , s.rfind(sub) 這兩個函數,如果完全匹配,才返回匹配的索引,即:當s中含有abc三個連續的字母時,才返回當前索引。s.find_first_of(sub), s網站優化seo培訓.find_first_not_of(sub), s.find_last_of(sub), s.find_last_not_of(sub) 這四個函數,查找s中含有sub中任意字母的索引。2.如果沒有查詢到,則返回string::npos,這是一個很大的數,其值不需要知道。相關網站建設企業網站建設。

關鍵詞標簽: 函數 深入

聲明: 本文由我的SEOUC技術文章主頁發布于:2023-05-24 ,文章深入C++ string.find()函數的用法總結建站知識主要講述函數,深入,深入C++ string.find()函數的用法網站建設源碼以及服務器配置搭建相關技術文章。轉載請保留鏈接: http://www.bifwcx.com/article/web_6384.html

我的IDC 網站建設技術SEOUC.COM
專注網站建設,SEO優化,小程序設計制作搭建開發定制網站等,數千家網站定制開發案例,網站推廣技術服務。
  • 5000+合作客服
  • 8年從業經驗
  • 150+覆蓋行業
  • 最新熱門源碼技術文章

    主站蜘蛛池模板: 上虞市| 波密县| 中牟县| 水富县| 涡阳县| 金门县| 沙洋县| 宜丰县| 民和| 延长县| 临邑县| 阿坝县| 米泉市| 华安县| 铜鼓县| 平昌县| 额济纳旗| 大关县| 罗城| 蛟河市| 梁山县| 宁强县| 馆陶县| 抚州市| 遂昌县| 永兴县| 当阳市| 阳山县| 原阳县| 金堂县| 饶平县| 孟州市| 石台县| 巴林右旗| 广元市| 枞阳县| 长子县| 西盟| 渝中区| 章丘市| 綦江县|