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

网站的域名做邮箱网络营销主要干什么

网站的域名做邮箱,网络营销主要干什么,冒险岛钓鱼网站做啥用,法律网站建设目录 1.c_str() 返回C常量字符串 2.date() 返回C常量字符串 3.substr() 构造子串 4.find() 正向查找(查找失败返回npos) 5.rfind() 逆向查找(查找失败返回npos) 6.find_first_of() 正向查找匹配的字符 7.find_last_of() 逆向…

目录

1.c_str() 返回C常量字符串

2.date() 返回C常量字符串

3.substr() 构造子串

4.find() 正向查找(查找失败返回npos)

5.rfind() 逆向查找(查找失败返回npos)

6.find_first_of() 正向查找匹配的字符

7.find_last_of() 逆向查找匹配的字符

8.find_first_not_of() 正向查找不匹配的字符

9.find_last_not_of() 逆向查找不匹配的字符

10.compare() 比较字符串


1.c_str() 返回C常量字符串

const char* c_str() const 

string s("123");
const char* p = s.c_str();
cout << p << endl;//123

2.date() 返回C常量字符串

const char* data() const

string s("12345");
const char* p = s.data();
cout << p << endl;//12345

3.substr() 构造子串

string substr(size_t pos = 0, size_t len = npos) const 

返回pos位置开始的len个字符组成的字符串

string s1 = "12345";
string s2 = s1.substr(2, 3);
cout << s2 << endl;//345

4.find() 正向查找(查找失败返回npos)

string (1)
size_t find (const string& str, size_t pos = 0) const;
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_t n) const;
character (4)
size_t find (char c, size_t pos = 0) const;

1.size_t find(const string& str, size_t  pos = 0) const 

从pos位置开始查找匹配的对象str,返回查找到的位置

2.size_t find(const char* s, size_t pos = 0) const 

从pos位置开始查找匹配的字符串s,返回查找到的位置

3.size_t find(const char* s, size_t pos, size_t n)

从pos位置查找匹配字符串s的前n个字符,返回查找到的位置

4.size_t find(char c, size_t pos = 0)

从pos位置开始查找字符c,返回查找到的位置

string s1("There are two needles in this haystack with needles.");
string s2("needle");
size_t found = s1.find(s2, 0);
if (found != string::npos)
{cout << "first 'needle' found at " << found << endl;//first 'needle' found at 14
}
else
{cout << "'needle' no found" << endl;
}found = s1.find("needle are small", found + 1, 6);
if (found != string::npos)
{cout << "second 'needle' found at " << found << endl;//second 'needle' found at 44
}
else
{cout << "'needle' no found" << endl;
}found = s1.find("haystack", 0);
if (found != string::npos)
{cout << "'haystack' found at " << found << endl;//'haystack' found at 30
}
else
{cout << "'haystack' no found" << endl;
}found = s1.find('.', 0);
if (found != string::npos)
{cout << "'.' found at " << found << endl;//'.' found at 30
}
else
{cout << "'.' no found" << endl;
}

5.rfind() 逆向查找(查找失败返回npos)

string (1)
size_t rfind (const string& str, size_t pos = npos) const;
c-string (2)
size_t rfind (const char* s, size_t pos = npos) const;
buffer (3)
size_t rfind (const char* s, size_t pos, size_t n) const;
character (4)
size_t rfind (char c, size_t pos = npos) const;

1.size_t rfind(const string& str, size_t pos =npos) const

从pos位置逆向开始查找匹配的对象str,返回查找到的位置

2.size_t rfind(const char* s, size_t pos =npos) const

从pos位置逆向开始查找匹配的字符串s,返回查找到的位置

3.size_t rfind(const char* s, size_t pos, size_t n) const

从pos位置逆向查找匹配字符串s的前n个字符,返回查找到的位置

4.size_t rfind(char c, size_t pos =npos) const

从pos位置逆向开始查找字符c,返回查找到的位置

string str("The sixth sick sheik's sixth sheep's sick.");
string key("sixth");
size_t found = str.rfind(key);
if (found != string::npos)cout << "'sixth' found at " << found << endl;//'sixth' found at 23

6.find_first_of() 正向查找匹配的字符

正向查找首个与指定字符串中任一字符匹配的字符,查找失败返回npos

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

1.size_t find_first_of(const string& str, size_t pos = 0) const 

从pos位置开始查找对象str中首次出现的任一字符,查找失败返回npos

2.size_t find_first_of(const char* s, size_t pos = 0) const

从pos位置开始查找字符串s中出现的任一字符,查找失败返回npos

3.size_t find_first_of(const char* s, size_t pos, size_t n) const 

从pos位置开始查找字符串s的前n个字符串中出现的任一字符,查找失败返回npos

4.size_t find_first_of(char c, size_t pos =0 ) const 

从pos位置开始查找首次出现的字符c,查找失败返回npos

string s("Please, replace the vowels in this sentence by asterisks.");
size_t found = s.find_first_of("aoeiu", 0);
while (found != string::npos)
{s[found] = '*';found = s.find_first_of("aoeiu", found + 1);
}
cout << s << endl;//Pl**s*, r*pl*c* th* v*w*ls *n th*s s*nt*nc* by *st*r*sks.

7.find_last_of() 逆向查找匹配的字符

逆向查找首个与指定字符串中任一字符匹配的字符,查找失败返回npos

string (1)
size_t find_last_of (const string& str, size_t pos = npos) const;
c-string (2)
size_t find_last_of (const char* s, size_t pos = npos) const;
buffer (3)
size_t find_last_of (const char* s, size_t pos, size_t n) const;
character (4)
size_t find_last_of (char c, size_t pos = npos) const;

1.size_t find_last_of(const string& str, size_t pos = npos) const

从pos位置开始逆向查找首个与对象str中任一字符匹配的字符,查找失败返回npos

2.size_t find_last_of(const char* s, size_t pos = npos) const

ni从pos位置开始逆向查找首个与字符串s中任意字符匹配的字符,查找失败返回npos

3.size_t find_last_of(const char* s,size_t pos, size_t n) const

从pos位置开始逆向查找首个与字符串s的前n个字符中任意字符匹配的字符,查找失败返回npos

4.size_t find_last_of(char c, size_t pos =npos) const

ni从pos位置开始逆向查找首个与字符c匹配的字符,查找失败返回npos

void SplitFilename(const string& str)
{size_t found = str.find_last_of("/\\");cout << "path :" << str.substr(0, found) << endl;cout << "file :" << str.substr(found + 1) << endl;
}
void string_test()
{string s1("/usr/bin/man");string s2("c:\\windows\\winhelp.exe");SplitFilename(s1);SplitFilename(s2);}
int main()
{string_test();//path: / usr / bin//file : man//path : c:\windows//file : winhelp.exereturn 0;
}

 8.find_first_not_of() 正向查找不匹配的字符

正向查找首个与指定字符串中任一字符不匹配的字符,查找失败返回npos

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

1.size_t find_first_not_of(const string& str, size_t pos = 0) const 

从pos位置开始正向查找首个与对象str中字符不匹配的字符,查找失败返回npos

2.size_t find_first_not_of(const char* s, size_t pos = 0) const

从pos位置开始正向查找首个与字符串s中字符不匹配的字符,查找失败返回npos

3.size_t find_first_not_of(const char* s, size_t pos, size_t n) const

从pos位置开始正向查找首个与字符串s前n个字符中字符不匹配的字符,查找失败返回npos

4.size_t find_first_not_of(char c, size_t pos = 0) const

从pos位置开始正向查找首个与字符c不匹配的字符,查找失败返回npos

string str("look for non-alphabetic characters...");
size_t found = str.find_first_not_of("abcdefghijklmnopqrstuvwxyz ");
if (found != string::npos)
{cout << "The first non-alphabetic character is " << str[found] << " at position " << found << endl;//The first non-alphabetic character is - at position 12
}

9.find_last_not_of() 逆向查找不匹配的字符

 逆向查找首个与指定字符串中任一字符不匹配的字符,查找失败返回npos

string (1)
size_t find_last_not_of (const string& str, size_t pos = npos) const;
c-string (2)
size_t find_last_not_of (const char* s, size_t pos = npos) const;
buffer (3)
size_t find_last_not_of (const char* s, size_t pos, size_t n) const;
character (4)
size_t find_last_not_of (char c, size_t pos = npos) const;

1.size_t find_last_not_of(const string& str, size_t pos = npos) const

从pos位置开始逆向查找首个与对象str中字符不匹配的字符,查找失败返回npos

2.size_t find_last_not_of(const char* s, size_t pos = npos) const

从pos位置开始逆向查找首个与字符串s中字符不匹配的字符,查找失败返回npos

3.size_t find_last_not_of(const char* s, size_t pos, size_t n) const

从pos位置开始逆向查找首个与字符串s前n个字符中字符不匹配的字符,查找失败返回npos

4.size_t find_last_not_of(char c, size_t pos = npos) const

从pos位置开始逆向查找首个与字符c不匹配的字符,查找失败返回npos

string str("Please, erase trailing white-spaces   \n");
string whitespaces(" \t\f\v\n\r");
size_t found = str.find_last_not_of(whitespaces);
if (found != string::npos)str.erase(found + 1);   //[Please, erase trailing white-spaces]
elsestr.clear();
cout << "[" << str << "]" << endl;

10.compare() 比较字符串

比较两个字符串的ASCII码值,字符串1大于字符串2返回大于0的数;字符串1等于字符串2返回0;字符串1小于字符串2返回小于0的数

string (1)
int compare (const string& str) const;
substrings (2)
int compare (size_t pos, size_t len, const string& str) const;
int compare (size_t pos, size_t len, const string& str,size_t subpos, size_t sublen) const;
c-string (3)
int compare (const char* s) const;
int compare (size_t pos, size_t len, const char* s) const;
buffer (4)
int compare (size_t pos, size_t len, const char* s, size_t n) const;

1.int compare(const string& str) const

比较调用对象和str对象的大小

2.int compare(size_t pos, size_t len, const string& str) const

比较调用对象pos位置开始的len个字符与对象str的大小

int compare(size_t pos, size_t len, const string& str, size_t subpos, size_t sublen) const

比较调用对象pos位置开始的len个字符与对象str中subpos位置开始的sublen个字符的大小

3.int compare(const char* s) const

比较调用对象和字符串s的大小

int compare(size_t pos, size_t len, const char* s) const

比较调用对象从pos位置开始的len个字符与字符串s的大小

4.int compare(size_t pos, size_t len, const char* s, size_t n) const

比较调用对象从pos位置开始的len个字符与字符串s前n个字符的大小

//1.
string s1("abcdefg");
string s2("abcdfg");
if (s1.compare(s2) == 0)cout << s1 << " = " << s2 << endl;
else if (s1.compare(s2) > 0)cout << s1 << " > " << s2 << endl;
elsecout << s1 << " < " << s2 << endl; //abcdefg < abcdfg//2.1
string s1("abcdefg");
string s2("abcdfg");
if (s1.compare(1, 6, s2) == 0)cout << s1 << " = " << s2 << endl;
else if (s1.compare(1, 6, s2) > 0)cout << s1 << " > " << s2 << endl;//abcdefg > abcdfg
elsecout << s1 << " < " << s2 << endl; //2.2
string s1("abcdefg");
string s2("abcdfg");
if (s1.compare(1, 6, s2, 1, 5) == 0)cout << s1 << " = " << s2 << endl;
else if (s1.compare(1, 6, s2, 1, 5) > 0)cout << s1 << " > " << s2 << endl;
elsecout << s1 << " < " << s2 << endl;//abcdefg < abcdfg//3.1
string s("abcdefg");
char p[] = "abcdfg";
if (s.compare(p) == 0)cout << s << " = " << p << endl;
else if (s.compare(p) > 0)cout << s << " > " << p << endl;
elsecout << s << " < " << p << endl;//abcdefg < abcdfg//3.2
string s("abcdefg");
char p[] = "abcdfg";
if (s.compare(1, 5, p) == 0)cout << s << " = " << p << endl;
else if (s.compare(1, 5, p) > 0)cout << s << " > " << p << endl;//abcdefg > abcdfg
elsecout << s << " < " << p << endl;//4
string s("abcdefg");
char p[] = "abcdfg";
if (s.compare(1, 5, p, 5) == 0)cout << s << " = " << p << endl;
else if (s.compare(1, 5, p, 5) > 0)cout << s << " > " << p << endl;//abcdefg > abcdfg
elsecout << s << " < " << p << endl;
http://www.yidumall.com/news/35398.html

相关文章:

  • 昆山seo网站优化软件品牌营销策划机构
  • 网站设置cookie什么意思描述建设一个网站的具体步骤
  • h5网站开发公司如何制作自己的网站教程
  • 前端网站搜索导航怎么做近期国际新闻
  • 遵义市政府网站建设概况专业搜索引擎seo服务
  • wordpress 整站源码最近时事新闻热点事件
  • 小县城做服务网站企业如何做好网络营销
  • 上海做网站的公黑科技引流推广神器免费
  • 英文手机商城网站建设长春最专业的seo公司
  • 锦州市城乡建设委员会官方网站百度云网页版入口
  • 秦皇岛城乡建设局网站百度打广告多少钱一个月
  • 哪里做网站网站seo李守洪排名大师
  • 自己电脑可以做网站服务器网页制作模板
  • 政府网站建设问卷调查淘宝网店怎么运营起来
  • 广州白云网站建设网络推广包括哪些
  • 天津河东区网站建设seo排名怎么样
  • 项目网址大全seo是什么意思 seo是什么职位
  • seo查询官网站长之家seo查找
  • 校园网页制作模板seo综合查询爱站
  • 注册工商企业seo搜索铺文章
  • 西安网站建设 招聘线下推广有哪几种渠道
  • 网站维护要多久时间公司的网站制作
  • 网站建设对教育解决方案开通网站需要多少钱
  • 网站建设 三合一网络软文营销的案例
  • 成都o2o网站建设淘宝seo优化是什么
  • 成都专业网站建设公司排名海外网站建站
  • 天津seo公司网站推广怎么做
  • 标志设计欣赏网站无锡做网站的公司
  • 诚信通国际网站怎么做私域营销
  • 临沂做商城网站百度公司名称