C++中String处理常用方法总结

字符串的题目大多是和模拟题挂钩,处理起来很麻烦,除非使用正则表达式,但是那玩意又很恶心。所以今天下午我就总结了一下C++里面关于字符串常用的方法,干货满满哦!
#include
#include
#include
#include
#include
#include
using namespace std;
int main(){
    cout<<"Commonly used string extraction methods\n";
    string s="xuhacker ni hao";
    string s1="h";
    string s3="zxcvbnm,./";
    unsigned long long i;
    //string s.find(s1,pos) return the location where s1 first appeared, and if pos does not exist, the default value of pos is zero
    if(s.find(s1)!=string::npos){
        i=s.find(s1);
        cout<<"the first position is: "< Remove two characters from 0
    cout<<"the first use of erase is "<>value;
        cout<<"print this value: "<>s9;//transform
    cout<<"transform s9: "<> a;
    cout<<"a is: "<>a" has used
    ss.clear();
    ss<<"234";
    ss>>b;
    cout<<"b is: "<

运行结果:

TIM截图20181124182930_test.png

你可能感兴趣的:(C++中String处理常用方法总结)