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, 没位置, 没找到
随机推荐
- μCos-ii学习笔记2_任务管理
二.任务管理 任务管理是ucos-ii操作系统的核心内容.这一章大致就以下流程来介绍和总结任务管理的相关知识. 要实现复杂任务管理,必然要定义众多数据来描述任务状态,为了精简,建立了许多不同的数据结构 ...
- wmic应用实例
实例应用 1.磁盘管理 查看磁盘的属性 wmic logicaldisk list brief ::caption=标题.driveID=驱动器ID号.model=产品型号.Partitions=分区 ...
- js 时间
<html> <head> <meta charset="utf-8" /> <title></title> <s ...
- CentOS + EPEL YUM源地址
[bizosv] name=bizsov-centos-$releasever - centos baseurl=http://yikat:yikat@download.bizsov.com/ gpg ...
- java memcache应用
import java.io.Serializable; import java.text.DateFormat; import java.util.Date; import java.util.Ma ...
- java模式:模板模式的简单理解
1.模板模式就是用虚类作为基类将几个要执行差不多操作中相同的部分提取出来,不同的部分各自实现! 2.下面给出简单栗子: 我要进行的操作是将大象和狐狸放入冰箱,放入大象和狐狸有相同的步骤:开冰箱和关冰箱 ...
- UVA 571 Jugs ADD18 小白书10 数学Part1 专题
只能往一个方向倒,如c1=3,c2=5,a b从0 0->0 5->3 2->0 2->2 0->2 5->3 4->0 4->3 1->0 1- ...
- JAVA面向对象3---多态
1. 多态:父类或者接口的引用 指向了子类对象. 多态的好处:提高了代码的扩展性 多态的弊端:父类不能调用子类的特有的内容. 多态的前提: 1.要有关系,继承或实现 2.要有覆盖(重写),因为父类不 ...
- xp安装maven
1.下载apache-maven-2.0.8 2.设置xp环境变量 MAVEN_HOME D:\apache-maven-2.0.8 在path里面假如 %MAVEN_HOME%\bin 然后打开c ...
- keyboardWillChangeFrameNotification 引发的思考 是的 思考了很久终于出结果
func keyboardWillChangeFrameNotification(note: NSNotification) { // TODO 添加键盘弹出的事件 let userinfo = no ...