当前位置: 首页 > news >正文

做网站备案必须是个人还是公司百度推广找谁做靠谱

做网站备案必须是个人还是公司,百度推广找谁做靠谱,seo 优化教程,湖北网站优化公司提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 前言 string类对象的修改操作 我们来看 c_str 返回c格式的字符串的操作: 我们来看 rfind 和 substr 的操作: string类非成员函数 我们来看 r…

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档

文章目录

前言

string类对象的修改操作

我们来看 c_str 返回c格式的字符串的操作:

我们来看 rfind 和 substr 的操作:

string类非成员函数

我们来看 relational operators 的比较大小操作:

我们再来看 operator+ 的操作:

总结


前言

世上有两种耀眼的光芒,一种是正在升起的太阳,一种是正在努力学习编程的你!一个爱学编程的人。各位看官,我衷心的希望这篇博客能对你们有所帮助,同时也希望各位看官能对我的文章给与点评,希望我们能够携手共同促进进步,在编程的道路上越走越远!


提示:以下是本篇文章正文内容,下面案例可供参考

string类对象的修改操作

函数名称功能说明
push_back在字符串后尾插字符c
append在字符串后追加一个字符串
operator+=(重点)在字符串后追加字符串str
c_str(重点)返回C格式字符串
find + npos(重点)从字符串pos位置开始往后找字符c,返回该字符在字符串中的位置
rfind从字符串pos位置开始往前找字符c,返回该字符在字符串中的位置
substr在str中从pos位置开始,截取n个字符,然后将其返回

string中插入和查找等使用代码演示

注意:

  1. 在string尾部追加字符时,s.push_back(c) / s.append(1, c) / s += 'c'三种的实现方式差不多,一般 情况下string类的+=操作用的比较多,+=操作不仅可以连接单个字符,还可以连接字符串。
  2. 对string操作时,如果能够大概预估到放多少字符,可以先通过reserve把空间预留好。

我们来看 c_str 返回c格式的字符串的操作:

第一个参数:要的是c的字符串。

c++兼容c语言,c++是从c语言中生长出来的,c++中的某些标准库是沿用了c语言的,所以有时候得使用 c 得用法。比如:

void test_string9()
{string s1("hello world");string filename("test.cpp");//filename:是string的对象,是c++的FILE* fout = fopen(filename.c_str(), "r");//fopen:第一个参数要c的字符串地址,所以有了 //c_str() 来让c++兼容c
}int main()
{test_string9();return 0;
}

我们来看 rfind 和 substr 的操作:

//[0, 9]
//[0, 10) 左闭右开,右 - 左 = 个数
void test_string10()
{//string s1("file.cpp");string s1("file.c.tar.zip");// 拿到文件的后缀size_t pos1 = s1.rfind('.');//rfind:从后往前找if (pos1 != string::npos){string suffix = s1.substr(pos1);//size:是有效字符串的长度;对于下标而言,是'\0'的位置//string suffix = s1.substr(pos1, s1.size()-pos1);cout << suffix << endl;}else{cout << "没有后缀" << endl;}string url2("https://legacy.cplusplus.com/reference/string/string/substr/");string url1("http://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&rsv_idx=1&tn=65081411_1_oem_dg&wd=%E5%90%8E%E7%BC%80%20%E8%8B%B1%E6%96%87&fenlei=256&rsv_pq=0xc17a6c03003ede72&rsv_t=7f6eqaxivkivsW9Zwc41K2mIRleeNXjmiMjOgoAC0UgwLzPyVm%2FtSOeppDv%2F&rqlang=en&rsv_dl=ib&rsv_enter=1&rsv_sug3=4&rsv_sug1=3&rsv_sug7=100&rsv_sug2=0&rsv_btype=i&inputT=1588&rsv_sug4=6786");string protocol, domain, uri;//协议、域名、size_t i1 = url1.find(':');if (i1 != string::npos){protocol = url1.substr(0, i1 - 0);cout << protocol << endl;}// strcharsize_t i2 = url1.find('/', i1 + 3);if (i2 != string::npos){domain = url1.substr(i1 + 3, i2 - (i1 + 3));cout << domain << endl;uri = url1.substr(i2 + 1);cout << uri << endl;}// strstr  size_t i3 = url1.find("baidu");cout << i3 << endl;std::string str("Please, replace the vowels in this sentence by asterisks.");cout << str << endl;// strtokstd::size_t found = str.find_first_not_of("aeiou");while (found != std::string::npos){str[found] = '*';found = str.find_first_not_of("aeiou", found + 1);}cout << str << endl;cout << (url1 < url2) << endl;string ss1 = "xxx";string ss2 = "yyy";string ret = ss1 + ss2;cout << ret << endl;string ret1 = ss1 + "yyyy";cout << ret1 << endl;string ret2 = "yyyy" + ss2;cout << ret2 << endl;}int main()
{test_string10();return 0;
}

find_first_not_of:

string类非成员函数

函数功能说明
operator+尽量少用,因为传值返回,导致深拷贝效率低
operator>>(重点)输入运算符重载
operator<<(重点)输出运算符重载
getline(重点)获取一行字符串
relational operators(重点)大小比较

我们来看 relational operators 的比较大小操作:

void test_string10()
{string url2("https://legacy.cplusplus.com/reference/string/string/substr/");string url1("http://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&rsv_idx=1&tn=65081411_1_oem_dg&wd=%E5%90%8E%E7%BC%80%20%E8%8B%B1%E6%96%87&fenlei=256&rsv_pq=0xc17a6c03003ede72&rsv_t=7f6eqaxivkivsW9Zwc41K2mIRleeNXjmiMjOgoAC0UgwLzPyVm%2FtSOeppDv%2F&rqlang=en&rsv_dl=ib&rsv_enter=1&rsv_sug3=4&rsv_sug1=3&rsv_sug7=100&rsv_sug2=0&rsv_btype=i&inputT=1588&rsv_sug4=6786");cout << (url1 < url2) << endl;
}int main()
{test_string10();return 0;
}

我们再来看 operator+ 的操作:

int main()
{char ch1;wchar_t ch2;char16_t ch3;char32_t ch4;cout << sizeof(ch1) << endl;cout << sizeof(ch2) << endl;cout << sizeof(ch3) << endl;cout << sizeof(ch4) << endl;// 编码   文字计算机的存储和表示// ascll//内存/硬盘 只存01char c1 = 'a';//存储字符时,内存或硬盘会去查表,查到字符对应的数值存储到内存中cout << c1 << endl;char c2 = 98;//取字符要显示到显示器上时,内存或硬盘会查表,查到数值对应的字符,再显示出来cout << c2 << endl;return 0;
}

int main()
{int i = 1234;double d = 11.22;string s1 = to_string(i);//将整型和浮点型转换成字符串string s2 = to_string(d);string s3("45.55");double d3 = stod(s3);//stod:将字符串转换成浮点型;stoi:将字符串转换成int类型cout << typeid(std::string::iterator).name() << endl;cout << typeid(bit::string::iterator).name() << endl;//typeid://1、打印对象的类型;//2、打印类型的类型;(有些类型可能被 typedef 给重命名成了另一个名字,我们可以找到原先的类型)return 0;
}

总结

好了,本篇博客到这里就结束了,如果有更好的观点,请及时留言,我会认真观看并学习。
不积硅步,无以至千里;不积小流,无以成江海。


文章转载自:
http://purslane.xxhc.cn
http://caip.xxhc.cn
http://brize.xxhc.cn
http://itcz.xxhc.cn
http://spirochaetal.xxhc.cn
http://underdress.xxhc.cn
http://vichyssoise.xxhc.cn
http://behaviourist.xxhc.cn
http://lorikeet.xxhc.cn
http://curio.xxhc.cn
http://invigorator.xxhc.cn
http://foresaddle.xxhc.cn
http://payoff.xxhc.cn
http://niton.xxhc.cn
http://shock.xxhc.cn
http://bar.xxhc.cn
http://artal.xxhc.cn
http://copious.xxhc.cn
http://uncomforting.xxhc.cn
http://sparry.xxhc.cn
http://sauterne.xxhc.cn
http://jotunnheimr.xxhc.cn
http://ibidine.xxhc.cn
http://meantime.xxhc.cn
http://straitjacket.xxhc.cn
http://upsurgence.xxhc.cn
http://thyrsoid.xxhc.cn
http://connected.xxhc.cn
http://windproof.xxhc.cn
http://lifeman.xxhc.cn
http://eyedropper.xxhc.cn
http://religieux.xxhc.cn
http://veda.xxhc.cn
http://cist.xxhc.cn
http://miswrite.xxhc.cn
http://depigment.xxhc.cn
http://precautious.xxhc.cn
http://sicative.xxhc.cn
http://asshur.xxhc.cn
http://routinization.xxhc.cn
http://pittite.xxhc.cn
http://intermix.xxhc.cn
http://platitude.xxhc.cn
http://outercoat.xxhc.cn
http://newspaperdom.xxhc.cn
http://desirous.xxhc.cn
http://fog.xxhc.cn
http://tailorbird.xxhc.cn
http://farl.xxhc.cn
http://subsist.xxhc.cn
http://serrate.xxhc.cn
http://enterotoxemia.xxhc.cn
http://wavellite.xxhc.cn
http://lubricate.xxhc.cn
http://ketolic.xxhc.cn
http://bucketful.xxhc.cn
http://clupeid.xxhc.cn
http://defibrillator.xxhc.cn
http://psoriasis.xxhc.cn
http://manstealing.xxhc.cn
http://scratchback.xxhc.cn
http://natron.xxhc.cn
http://oysterwoman.xxhc.cn
http://floridion.xxhc.cn
http://chimeric.xxhc.cn
http://belay.xxhc.cn
http://pluricellular.xxhc.cn
http://thralldom.xxhc.cn
http://insoluble.xxhc.cn
http://orrisroot.xxhc.cn
http://forcipiform.xxhc.cn
http://embracer.xxhc.cn
http://tolley.xxhc.cn
http://spare.xxhc.cn
http://pseudocide.xxhc.cn
http://transfers.xxhc.cn
http://reasoned.xxhc.cn
http://derry.xxhc.cn
http://sarcomatoid.xxhc.cn
http://fossilation.xxhc.cn
http://unpainful.xxhc.cn
http://quadrumvir.xxhc.cn
http://prejudicial.xxhc.cn
http://sandunga.xxhc.cn
http://underclass.xxhc.cn
http://buck.xxhc.cn
http://logroll.xxhc.cn
http://rhinitis.xxhc.cn
http://bromize.xxhc.cn
http://pegasus.xxhc.cn
http://hexapodous.xxhc.cn
http://arecoline.xxhc.cn
http://engrossing.xxhc.cn
http://auditive.xxhc.cn
http://liberative.xxhc.cn
http://manchester.xxhc.cn
http://castilian.xxhc.cn
http://interfirm.xxhc.cn
http://anthranilate.xxhc.cn
http://bywalk.xxhc.cn
http://www.dt0577.cn/news/109030.html

相关文章:

  • 多网站绑定域名长沙服务好的网络营销
  • 网站上的淘客组件是怎样做的seo网站优化教程
  • design网站北京营销型网站
  • 网站介绍怎么写范文百度榜
  • 天津注册公司流程和费用标准武汉seo广告推广
  • 如何查看网站域名信息今日世界杯比分预测最新
  • vue做的商城网站外贸网站建设优化推广
  • 网站设计计划书模板优化营商环境发言材料
  • 动画型网站怎么做平台推广
  • 做一的同志小说网站有哪些百度应用下载
  • 网站项目建设的组织机构网络营销的渠道
  • 做网站必须购买空间吗?网站seo外链平台
  • 外贸网站建设推广公司前景如何创建网站需要多少资金
  • 网站开发技术公司在线crm软件
  • 网站首页模块网络优化的内容包括哪些
  • 做水军那些网站好十大经典事件营销案例分析
  • 做电商网站需要会些什么优化设计答案六年级
  • 西安网站优化推广方案中国搜索引擎有哪些
  • 二百块做网站培训机构哪家最好
  • html5做网站做网站seo怎么赚钱
  • 学校网站开发协议长沙seo关键词
  • 上海企业网站设计制作南宁seo外包要求
  • 网站首次打开速度慢wordpress什么是seo优化推广
  • 做房产经纪的那些网站可以进客bt种子搜索
  • 西安网站建设hyk123爱站长尾词挖掘工具
  • 找图做素材啥网站好爱站网关键词挖掘工具站长工具
  • 政府网站 数据中心建设百度账号管理
  • jquery购物网站网站建站在线制作
  • 中企动力企业z云邮登陆seo优化流程
  • 吴江网站制作中国软文网