zoukankan      html  css  js  c++  java
  • String

    
    
     1 #include<cstdio>
     2 #include<string>
     3 #include<iostream>
     4 using namespace std;
     5 
     6 int main()
     7 {
     8     string str="i love you";
     9     cout<<str<<endl;
    10     string::iterator ptr;       //智能指针
    11     for(ptr=str.begin();ptr!=str.end();ptr++)
    12         cout<<*ptr<<"";
    13     cout<<endl;
    14     string Cstr;
    15     Cstr=str;
    16     cout<<Cstr<<endl;
    17     Cstr+=str;
    18     cout<<Cstr<<endl;
    19     bool ans=(Cstr==str);
    20     cout<<ans<<endl;;
    21     string CCstr;
    22     CCstr=Cstr+str;
    23     cout<<CCstr<<endl;
    24     CCstr.erase(CCstr.begin(),CCstr.end());
    25     cout<<CCstr.size()<<endl;
    26     Cstr.erase(0,10);
    27     cout<<Cstr<<endl;
    28     Cstr.erase(Cstr.begin());
    29     cout<<Cstr<<endl;
    30     Cstr.insert(0,"123456");
    31     cout<<Cstr<<endl;
    32     Cstr.insert(0,"123456",2,3);
    33     cout<<Cstr<<endl;
    34     string Fstr="i love you";
    35     string Sstr="u";
    36     int index=Fstr.find_first_of(Sstr);  //查找Sstr字符串中的任意一个字符在Fstr中最开始出现的位置
    37     cout<<index<<endl;
    38     index=Fstr.find_last_of(Sstr);       //查找Sstr字符串中任意一个字符在Fstr中最末尾出现的位置
    39     cout<<index<<endl;
    40     return 0;
    41 }
     
  • 相关阅读:
    JSON
    vue中跳转页面逻辑
    生命周期的几个阶段
    vue学习大纲
    Vue留言 checked框案列
    Vue内容
    linux -- iptables
    linux --- DNS
    linux --- samba
    linux --- vsftp
  • 原文地址:https://www.cnblogs.com/zafuacm/p/3185853.html
Copyright © 2011-2022 走看看