zoukankan      html  css  js  c++  java
  • string

    #include "stdafx.h"
    #include<string>
    #include<list>
    #include<iostream>
    using namespace std;
    int _tmain(int argc, _TCHAR* argv[])
    {
     string str("abc");
     str[0] ;
     cout << str[0] << endl;
     cout << str.c_str()<<endl;//输出abc
     string str2("123");
     str = str + str2;
     cout << str << endl;
     str = str + "esf" + "++";
     cout << str << endl;
     cout << "*******************************" << endl;

     int pos=str.find("_");//找到加号,并返回该加号的索引值,//如果没找到就返回-1,找到返回索引值
     cout << pos << endl;
     pos = str.find_first_not_of('+');//找第一个不是加号的,并返回索引值
     cout << pos << endl;
     pos = str.find_first_of('+');//找第一个是加号的,并返回索引值
     pos = str.find_last_not_of('+'); //找最后一个不是加号的,并返回索引值
     pos = str.find_first_of('+');//找最后一个是加号的,并返回索引值

     cout << "*****************************" << endl;
     //string strsub = str.substr(0,3);//获得【0,3)的子串
     string strsub = str.substr(3);//获得3到后面的子串
     cout << strsub << endl;
     cout << "*****************************" << endl;

     list<string>  strlist;//一个string类型的list容器
     return 0;
    }

  • 相关阅读:
    mybaits源码分析--事务管理(八)
    mybaits源码分析--binding模块(五)
    mybaits源码分析--自定义插件(七)
    mybaits源码分析--缓存模块(六)
    2021年9月
    golang-reflect实战ini配置文件
    ECC加密原理详解
    RFID 随手记
    计算机实现加法
    公钥加密算法 RSA
  • 原文地址:https://www.cnblogs.com/rong123/p/7727646.html
Copyright © 2011-2022 走看看