string比较字符串某个指定的字符串
生活随笔
收集整理的這篇文章主要介紹了
string比较字符串某个指定的字符串
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
string data="eewertyui";
比較索引3字母是e的話,移除該字母,不是則忽略。
string data="eqwertyui"; if(data.compare(3,1,"e",0,1)==0) {data=data.erase(3,1); }compare()函數(shù)??
類 basic_string 的成員函數(shù) compare() 的原型如下:
int compare (const basic_string& s) const;
int compare (const Ch* p) const;
int compare (size_type pos, size_type n, const basic_string& s) const;
int compare (size_type pos, size_type n, const basic_string& s,size_type pos2, size_type n2) const;
int compare (size_type pos, size_type n, const Ch* p, size_type = npos) const;
總結(jié)
以上是生活随笔為你收集整理的string比较字符串某个指定的字符串的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 国产统一操作系统UOS使用体验
- 下一篇: centos 安装ftp FileZil