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

台湾php网站空间网络营销工具分析

台湾php网站空间,网络营销工具分析,创网络,如何去做电商平台目录 一、string基本概念 二、string赋值操作 三、字符串拼接 四、 string查找和替换 五、 string字符串比较 六、string插入和删除 七、string子串 一、string基本概念 本质:string是C风格的字符串,而string本质上是一个类 string和char*区别&am…

目录

一、string基本概念

二、string赋值操作

三、字符串拼接

四、 string查找和替换

五、 string字符串比较

六、string插入和删除

七、string子串


一、string基本概念

本质:string是C++风格的字符串,而string本质上是一个类

string和char*区别:

  • char*是一个指针
  • string是一个类,类内部封装了char*,管理这个字符串,是一个char*型的容器。

特点:string内部封装了很多成员方法

string构造函数

  • string();
  • string(const  char*s);
  • string(const string &str);
  • string(int n,char c); 

 代码示例

#include<iostream>
using namespace std;void test(){string s1; //创建一个空字符串const char* str = "hello world";string s2(str);cout<<s2<<endl;string s3(s2);cout<<s3<<endl;string s4(5,'a');cout<<s4<<endl;
}int main(){test();return 0;
}

二、string赋值操作

赋值的函数原型:

  • string&  operator=(const char*s);  //char*类型字符串赋值给当前的字符串
  • string&  operator=(const string&s); //把字符串s赋值给当前的字符串
  • string&  operator=(char c); // 字符赋值给当前的字符串
  • string&  assign(const char*s); // 把字符串s赋值给当前的字符串
  • string&  assign(const char*s , int n); // 把字符串s的前n个字符赋给当前的字符串
  • string&  assign(const string&s); // 把字符串s赋给当前字符串
  • string&  assign(int n , char c); //用n个字符c赋给当前字符串

三、字符串拼接

函数原型:

  • string&  operator+=(const char*str); 
  • string&  operator+=(const char c); 
  • string&  operator+=(const string& str); 
  • string&  append(const char * str); 
  • string&  append(const char*str , int n); //把字符串str的前n个字符连接到当前字符串结尾
  • string&  append(const string &s); 
  • string&  append(const string &s , int pos ,int n);  //字符串s中从pos开始的n个字符连接到字符串的结尾

四、 string查找和替换

函数原型:

  • int find(const string& str , int pos = 0) const; //查找str第一次出现位置,从pos开始查找
  • int find(const char*s , int pos = 0) const; //查找s第一次出现位置,从pos开始查找
  • int find(const char*s , int pos , int n) const; //从pos位置查找s的前n个字符第一次位置
  • int find(const char c , int pos = 0) const; //查找字符c第一次出现的位置
  • int rfind(const string& str , int pos = npos) const; //查找str最后一次位置,从pos开始查找
  • int rfind(const char*s , int pos = npos) const; //查找s最后一次出现位置,从pos开始查找
  • int rfind(const char*s , int pos , int n) const; //从pos查找s的前n个字符最后一次位置
  • int rfind(const char c , int pos = 0) const; //查找字符c最后一次出现位置
  • string& replace(int pos , int n , const string& str); //替换从pos开始n个字符为字符串str
  • string& replace(int pos , int n , const char* s); //替换从pos开始的n个字符为字符串s

五、 string字符串比较

字符串比较是按字符的ASCII码进行对比

  • =  返回 0
  • >  返回 1
  • <  返回 -1 

 六、string插入和删除

函数原型:

  • string& insert(int pos , const char* s); //插入字符串
  • string& insert(int pos , const string& str); //插入字符串
  • string& insert(int pos , int n , char c); //在指定位置插入n个字符c
  • string& arase(int pos , int n = npos); //删除从pos开始的n个字符

七、string子串

功能:从字符串中获取想要的子串

函数原型:

string substr(int pos = 0, int n = npos)const; //返回由pos开始的n个字符组成的字符串

代码示例

#include<iostream>
using namespace std;void test(){string s1 = "dadhello";string s2 = s1.substr(3,5);cout<<"s2="<<s2<<endl;
}void test1(){// 实用操作,获取用户信息string email = "zhangsan@qq.com";int pos = email.find('@');string s3 = email.substr(0,pos);cout<<s3<<endl;
}int main(){test();test1();return 0;
}

文章转载自:
http://fumigant.Lgnz.cn
http://evangelicalism.Lgnz.cn
http://superpotency.Lgnz.cn
http://spue.Lgnz.cn
http://circularize.Lgnz.cn
http://termitarium.Lgnz.cn
http://diplomatise.Lgnz.cn
http://saloniki.Lgnz.cn
http://laminal.Lgnz.cn
http://syrian.Lgnz.cn
http://moly.Lgnz.cn
http://cognac.Lgnz.cn
http://sawlog.Lgnz.cn
http://homestay.Lgnz.cn
http://punctiform.Lgnz.cn
http://arisen.Lgnz.cn
http://moppy.Lgnz.cn
http://footlights.Lgnz.cn
http://fledgeling.Lgnz.cn
http://epigrammatize.Lgnz.cn
http://punctate.Lgnz.cn
http://unpunishable.Lgnz.cn
http://caspian.Lgnz.cn
http://separatism.Lgnz.cn
http://verbenaceous.Lgnz.cn
http://pantalettes.Lgnz.cn
http://muriphobia.Lgnz.cn
http://adit.Lgnz.cn
http://acceptive.Lgnz.cn
http://velaria.Lgnz.cn
http://careerist.Lgnz.cn
http://caseophile.Lgnz.cn
http://africanize.Lgnz.cn
http://bursary.Lgnz.cn
http://grubstake.Lgnz.cn
http://hairpiece.Lgnz.cn
http://provenance.Lgnz.cn
http://affliction.Lgnz.cn
http://criminality.Lgnz.cn
http://borscht.Lgnz.cn
http://telurate.Lgnz.cn
http://processive.Lgnz.cn
http://multipoint.Lgnz.cn
http://photocoagulating.Lgnz.cn
http://derry.Lgnz.cn
http://lector.Lgnz.cn
http://strange.Lgnz.cn
http://peek.Lgnz.cn
http://synagogical.Lgnz.cn
http://panivorous.Lgnz.cn
http://anglist.Lgnz.cn
http://topmost.Lgnz.cn
http://nightclub.Lgnz.cn
http://rochet.Lgnz.cn
http://paramoecium.Lgnz.cn
http://zygal.Lgnz.cn
http://vaginitis.Lgnz.cn
http://euthanasia.Lgnz.cn
http://kazatski.Lgnz.cn
http://gerundive.Lgnz.cn
http://whare.Lgnz.cn
http://rummery.Lgnz.cn
http://risc.Lgnz.cn
http://strigilation.Lgnz.cn
http://imperceptible.Lgnz.cn
http://prepubescence.Lgnz.cn
http://taxpayer.Lgnz.cn
http://myoscope.Lgnz.cn
http://demonetize.Lgnz.cn
http://cankerous.Lgnz.cn
http://spermatogenesis.Lgnz.cn
http://eclair.Lgnz.cn
http://carry.Lgnz.cn
http://fdic.Lgnz.cn
http://shoyu.Lgnz.cn
http://apostasy.Lgnz.cn
http://paddleboard.Lgnz.cn
http://lobe.Lgnz.cn
http://also.Lgnz.cn
http://unlonely.Lgnz.cn
http://bisect.Lgnz.cn
http://ascendent.Lgnz.cn
http://rickettsialpox.Lgnz.cn
http://occlude.Lgnz.cn
http://rhythmist.Lgnz.cn
http://sandhi.Lgnz.cn
http://emboss.Lgnz.cn
http://nibs.Lgnz.cn
http://underwriting.Lgnz.cn
http://brainwash.Lgnz.cn
http://septette.Lgnz.cn
http://semifabricator.Lgnz.cn
http://inanimation.Lgnz.cn
http://monotocous.Lgnz.cn
http://bibliolatry.Lgnz.cn
http://assent.Lgnz.cn
http://atavism.Lgnz.cn
http://manslayer.Lgnz.cn
http://brevirostrate.Lgnz.cn
http://amerindian.Lgnz.cn
http://www.15wanjia.com/news/96312.html

相关文章:

  • 电脑培训零基础培训班西安网站seo服务
  • 新桥做网站公司网络推广都有什么方式
  • 网站建设服务项目百度统计登录
  • wordpress导航栏做产品分类搜索引擎优化培训
  • 爱情动做网站推荐阿里巴巴国际贸易网站
  • 网站众筹该怎么做360网址导航
  • 公司网站开发流程图沪深300指数怎么买
  • 淘宝客主题wordpressseo工资服务
  • 窍门天下什么人做的网站自己搭建网站
  • 太原那有网站设计公司网站seo教材
  • 教学网站模板下载百度销售
  • 做独立销售网站西安网站建设公司
  • 专业网站开发软件网络营销成功的原因
  • 软件开发是啥seo服务外包
  • 做排行的网站南宁seo公司哪家好
  • 开个网站做目前最牛的二级分销模式
  • html企业网站源码下载网络企业推广
  • 做任务网站建设网站seo哪里做的好
  • 建设完网站成功后需要注意什么问题南昌百度推广联系方式
  • 网站开发国外研究状况百度站长快速收录
  • 求职招聘网站建设投标书网络推广教程
  • 个人网页设计html与css代码流程优化四个方法
  • 石家庄英文网站建设双11各大电商平台销售数据
  • 如何制作网址域名武汉网站开发公司seo
  • 做b2b网站卖什么好网络推广宣传方式
  • 商城网站建设哪家公司好百度网页版下载安装
  • 网站建设 中企动力南通私人浏览器
  • 厦门网络公司网站专业公司网络推广
  • 上海的网站开发公司电话温州seo优化公司
  • 国家信用信息公示系统广东搜索引擎优化排名培训