std::string
/*************************************************************************
> 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的更多相关文章
- QString 和std::string互转
std::string cstr; QString qstring; //****从std::string 到QString qstring = QString(QString::fromLocal8 ...
- std::string的split函数
刚刚要找个按空格分离std::string的函数, 结果发现了stackoverflow上的这个问题. 也没仔细看, 直接拿来一试, 靠, 不对啊, 怎么分离后多出个空字符串, 也就是 "a ...
- could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string'
VS2008, 写一个简单的demo的时候出现了这个: 1>------ Build started: Project: GetExportTable, Configuration: Relea ...
- 源码阅读笔记 - 3 std::string 与 Short String Optimization
众所周知,大部分情况下,操作一个自动(栈)变量的速度是比操作一个堆上的值的速度快的.然而,栈数组的大小是在编译时确定的(不要说 C99 的VLA,那货的 sizeof 是运行时计算的),但是堆数组的大 ...
- CString std::string相互转换
CString->std::string 例子: CString strMfc=“test“; std::string strStl; strStl=strMfc.GetBuffer(0); s ...
- 计算std:string的字节长度
如果项目本身是使用 Unicode 字符集和utf8编码,std::string的length(),size()甚至是c的strLen取到的都是字节长度了,比如三个汉字,就是9, 以上情况不满足的话, ...
- 【原】error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string'
今天遇到一个非常难以排查的BUG,谷歌度娘都问过了依旧无解,最后自己重新尝试之后找到解决方案: 先看一下报错信息: 1>.\lenz.cpp(2197) error C2679: binary ...
- 类型安全且自动管理内存的返回 std::string 的 sprintf 实现
在这篇博文里,我提到了一个例子,说的是使用C++实现类型安全的printf.这个例子很惊艳,但是在我写程序的时候,并非那么"迫切"地需要它出现在我的工具箱中,因为它并不比普通的pr ...
- VC++ 中使用 std::string 转换字符串编码
目录 第1章说明 1 1.1 代码 1 1.2 使用 4 第1章说明 VC++中宽窄字符串的相互转换比较麻烦,借助std::string能大大减少代码量. 1.1 代码 函数声明如下 ...
- std::string::npos mean
std::string::npos 表示 no position, 没位置, 没找到
随机推荐
- 轻松学会文本处理工具之二 linux sed命令
sed命令的语法格式: sed的命令格式: sed [option] 'sed command'filename sed的脚本格式:sed [option] -f 'sed script'fil ...
- redis运维的一些知识点
恰好看到一些redis需要主要的东西 记下 供参考 原文地址 http://hi.baidu.com/ywdblog/item/1a8c6ed42edf01866dce3fe3 最近在线上实际使用了一 ...
- hdu_2227_Find the nondecreasing subsequences_树状数组,离散化
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2227 题意:给你一个集合,让你求递增子序列有多少个,和树状数组求逆序对差不多,不过数据比较大,要离散化 ...
- greatest common divisor
One efficient way to compute the GCD of two numbers is to use Euclid's algorithm, which states the f ...
- Mysql:输出到文件
mysql>tee /home/a.txt mysql>show processlist; mysql>exit tee命令能重定向输出,同时屏幕会同步显示.
- 【我与一道水题的抗争之路】 哈理工2323 Emirp(反素数)
题目: http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=2323 1,打表的姿势不对. ...
- linux 进程监控和自动重启的简单实现(转)
目的:linux 下服务器程序会因为各种原因dump掉,就会影响用户使用,这里提供一个简单的进程监控和重启功能. 实现原理:由定时任务crontab调用脚本,脚本用ps检查进程是否存在,如果不存在则重 ...
- Qt之QTextCodec乱谈
何处开始呢? 一旦在Qt程序中出现latin1字符集以外的字符,几乎大家无一例外的会用到 QTextCodec. 而不少网友不分青红皂白,一旦用到中文,就同时使用下面3条指令(其中textc 取为 g ...
- php添加gd
一 GD简介: php处理图形的扩展库,提供了一系列用来处理图片的API.如果开发过程中发现有页面验证码不能显示,则要考虑检查phpinfo(),是否支持GD库. 二 思路: 网上发现添加GD库的方法 ...
- 转 Linux下的GoldenGate的启动关闭Shell脚本(独立)
用户想要用OGG进行同步数据,原来用的是Shareplex,至于为啥要换OGG,BulaBula一堆原因.....这不是我们要在意的事情,和客 户装完配置好OGG之后,测试中,客户提出要有个简单的启动 ...