/*************************************************************************
> 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. maven 代理

    切换到{maven.home}\conf (ie: maven 安装目录) 拷贝settings.xml到自己的.m2目录 编辑.m2/settings.xml的代理部分: <proxy> ...

  2. LD_LIBRARY_PATH vs LIBRARY_PATH

    LIBRARY_PATH is used by gcc before compilation to search for directories containing libraries that n ...

  3. LeetCode OJ 83. Remove Duplicates from Sorted List

    Given a sorted linked list, delete all duplicates such that each element appear only once. For examp ...

  4. 决策树J48算法

    1.J48原理 基于从上到下的策略,递归的分治策略,选择某个属性放置在根节点,为每个可能的属性值产生一个分支,将实例分成多个子集,每个子集对应一个根节点的分支,然后在每个分支上递归地重复这个过程.当所 ...

  5. webstrom 快捷键(Idea可用)

    在File-->setting可查看和配置功能快捷键,以下列出常用的快捷键 1. ctrl + shift + n: 打开工程中的文件,目的是打开当前工程下任意目录的文件. 2. ctrl + ...

  6. MySQL 索引 总结

    1.索引的种类(六种) 普通索引,唯一索引,全文索引,单列索引,多列索引,空间索引 2.优缺点及注意事项 优点:有了索引,对于记录数量很多的表,可以提高查询速度. 缺点:索引是占用空间的,索引会影响u ...

  7. 高可用开源方案 Keepalived VS Heartbeat对比

    最近因为项目需要,简单的试用了两款高可用开源方案:Keepalived和Heartbeat.两者都很流行,但差异还是很大的,现将试用过程中的感受以及相关知识点简单总结一下,供大家选择方案的时候参考. ...

  8. perl的USE和require

    来源: http://www.cnblogs.com/itech/archive/2010/11/22/1884345.html 相同: 都可以用来引用module(.PM). 不同: 1) 区别在于 ...

  9. photoshop 魔术橡皮擦

    魔术棒和橡皮的结合,不用解锁就能抠图

  10. nm applet disable

    http://support.qacafe.com/knowledge-base/how-do-i-prevent-network-manager-from-controlling-an-interf ...