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;
    }

  • 相关阅读:
    Spring启动流程
    bash脚本
    初识RPC框架
    C++ 全局变量、局部变量、静态全局变量、静态局部变量的区别
    MacOS安装vs code并且配置C/C++环境2020
    numpy 数组操作
    numpy索引 切片和迭代
    numpy基础之数据类型
    numpy基础
    Bootstrap Navbar应用及源码解析
  • 原文地址:https://www.cnblogs.com/rong123/p/7727646.html
Copyright © 2011-2022 走看看