/*************************************************************************
> File Name: string.cpp
> Author: lukey
> Mail: lukey123@foxmail.com
> Created Time: Wed 10 Jun 2015 09:21:32 PM CST
************************************************************************/ #include<iostream>
//using namespace std; int main(int argc, char* argv[])
{
std::string str1 = "hello";
std::string str2("world");
std::cout << "str1:" << str1 << std::endl;
std::cout << "str2:" << str2 << std::endl;
std::string str3 = str1 + str2;
std::cout << "str3:" << str3 << std::endl;
std::string sub1 = str3.substr(,);
std::string sub2 = str3.substr(,);
std::string sub3 = str3.substr(,);
std::string sub4 = str3.substr(,);
std::cout << "sub1:" << sub1 << std::endl;
std::cout << "sub2:" << sub2 << std::endl;
std::cout << "sub3:" << sub3 << std::endl;
std::cout << "sub4:" << sub4 << std::endl; return ;
}

std::string的更多相关文章

  1. QString 和std::string互转

    std::string cstr; QString qstring; //****从std::string 到QString qstring = QString(QString::fromLocal8 ...

  2. std::string的split函数

    刚刚要找个按空格分离std::string的函数, 结果发现了stackoverflow上的这个问题. 也没仔细看, 直接拿来一试, 靠, 不对啊, 怎么分离后多出个空字符串, 也就是 "a ...

  3. could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string'

    VS2008, 写一个简单的demo的时候出现了这个: 1>------ Build started: Project: GetExportTable, Configuration: Relea ...

  4. 源码阅读笔记 - 3 std::string 与 Short String Optimization

    众所周知,大部分情况下,操作一个自动(栈)变量的速度是比操作一个堆上的值的速度快的.然而,栈数组的大小是在编译时确定的(不要说 C99 的VLA,那货的 sizeof 是运行时计算的),但是堆数组的大 ...

  5. CString std::string相互转换

    CString->std::string 例子: CString strMfc=“test“; std::string strStl; strStl=strMfc.GetBuffer(0); s ...

  6. 计算std:string的字节长度

    如果项目本身是使用 Unicode 字符集和utf8编码,std::string的length(),size()甚至是c的strLen取到的都是字节长度了,比如三个汉字,就是9, 以上情况不满足的话, ...

  7. 【原】error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string'

    今天遇到一个非常难以排查的BUG,谷歌度娘都问过了依旧无解,最后自己重新尝试之后找到解决方案: 先看一下报错信息: 1>.\lenz.cpp(2197)  error C2679: binary ...

  8. 类型安全且自动管理内存的返回 std::string 的 sprintf 实现

    在这篇博文里,我提到了一个例子,说的是使用C++实现类型安全的printf.这个例子很惊艳,但是在我写程序的时候,并非那么"迫切"地需要它出现在我的工具箱中,因为它并不比普通的pr ...

  9. VC++ 中使用 std::string 转换字符串编码

    目录 第1章说明    1 1.1 代码    1 1.2 使用    4 第1章说明 VC++中宽窄字符串的相互转换比较麻烦,借助std::string能大大减少代码量. 1.1 代码 函数声明如下 ...

  10. std::string::npos mean

    std::string::npos 表示 no position, 没位置, 没找到

随机推荐

  1. js循环POST提交添加辅助单位

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...

  2. MySQL安装--ubuntu

    1. 执行命令: $ apt-get install mysql-server 执行上述命令会自动安装mysql-client,mysql-common等包. 2. 安装过程中会让你给root账号设置 ...

  3. linux配置java环境变量(转)

    linux配置java环境变量(详细) 一. 解压安装jdk 在shell终端下进入jdk-6u14-linux-i586.bin文件所在目录, 执行命令 ./jdk-6u14-linux-i586. ...

  4. hdu_5753_Permutation Bo(找规律)

    题目连接:hdu_5753_Permutation Bo 题意: 给你一个有n个数的数列c1~cn,h1~hn为1~n的排列,求ci[hi>hi-1  and  hi>hi+1]的期望和. ...

  5. spark第一篇--简介,应用场景和基本原理

    摘要: spark的优势:(1)图计算,迭代计算(2)交互式查询计算 spark特点:(1)分布式并行计算框架(2)内存计算,不仅数据加载到内存,中间结果也存储内存 为了满足挖掘分析与交互式实时查询的 ...

  6. MC 在1分钟图拿出5分钟,15分钟,30分钟,1小时的K线

    using System; using System.Drawing; using System.Linq; using System.Collections; namespace PowerLang ...

  7. dede 转 帝国

    1.转换栏目 insert into ak_enewsclass (classid,bclassid,classname,myorder,classpath,intro,classpagekey) s ...

  8. Rsync数据远程同步备份

    rsync的使用方法 一.设置Rsync Server端 Rsync server需要设定四个方面: 1.规划建立备份目录区 2.设定: /etc/xinetd.d/rsync 3.设定: /etc/ ...

  9. Windows GTK+ 环境搭建(详解)

    来源:http://blog.sina.com.cn/s/blog_a6fb6cc901017ygy.html Windows GTK+ 环境搭建 最近要做界面的一些东西,但是对微软提供的类库MFC不 ...

  10. Shell script fails: Syntax error: “(” unexpected

    Shell script fails: Syntax error: “(” unexpected google 一下. http://unix.stackexchange.com/questions/ ...