zoukankan      html  css  js  c++  java
  • std::string

     1 /*************************************************************************
     2     > File Name: string.cpp
     3     > Author: lukey
     4     > Mail: lukey123@foxmail.com 
     5     > Created Time: Wed 10 Jun 2015 09:21:32 PM CST
     6  ************************************************************************/
     7 
     8 #include<iostream>
     9 //using namespace std;
    10 
    11 int main(int argc, char* argv[])
    12 {
    13     std::string str1 = "hello";
    14     std::string str2("world");
    15     std::cout << "str1:" << str1 << std::endl;
    16     std::cout << "str2:" << str2 << std::endl;
    17     std::string str3 = str1 + str2;
    18     std::cout << "str3:" << str3 << std::endl;
    19     std::string sub1 = str3.substr(0,5);
    20     std::string sub2 = str3.substr(8,2);
    21     std::string sub3 = str3.substr(8,8);
    22     std::string sub4 = str3.substr(10,2);
    23     std::cout << "sub1:" << sub1 << std::endl;
    24     std::cout << "sub2:" << sub2 << std::endl;
    25     std::cout << "sub3:" << sub3 << std::endl;
    26     std::cout << "sub4:" << sub4 << std::endl;
    27     
    28     
    29     return 0;
    30 }
  • 相关阅读:
    Java: 数据类型
    数据结构是什么
    数据结构:进制转换
    数据结构:堆与栈
    class的写法
    Java:异常体系
    数据结构: 先进后出——堆栈
    tomcat:web容器
    Windows: Dos命令
    面向函数范式编程
  • 原文地址:https://www.cnblogs.com/luolizhi/p/4567364.html
Copyright © 2011-2022 走看看