#include<string> #include<cstring>

C++ strings

string 只能用cin,cout处理,不能 用scanf(),和printf()

transform( s.begin(),s.end(),s.begin(),::tolower );   转换成小写的函数
transform( s.begin(),s.end(),s.begin(),::toupper );  转换成大写的函数 

 sstream

C++继承了c的library

strlen(),strcpy(),strcat(),strcmp()         

特殊字符的输出:::back slash  \

输出   

 

	string str = "\"hello\" world!!";
	cout << str << endl;

  //string input

//string 类型可以直接比较string comparisons

string str,str2;
if(str>str2)
if(str==str2)
if(str<str2)

//下图本是定义的时候,习惯写成了赋值initiallisation

//字符串的赋值assingment

 //交换Swapping strings

        

//string concatention(连接)

 //string length,string indexing and sub-strings

substr(a,b);

第一个参数是起始的坐标,第二个参数个数,从起始的坐标的开始输出

                   

 //string replace,erase,insert and empty strings

 

 erase删除中间或者头上的内容,后面的内容自动向前补齐

#include<iostream>
#include<string>

using namespace std;

int main()
{
	string str = "1234567890";

	str.erase(1, 2);
	cout << str.at(1) << endl;

	return 0;

}

输出是    4

 //插入insert

 //查找

 

//string conversons

vs2019中为了安全使用  _s  这种做法,但并不是所有的都是这样,竞赛中一般都不这样做

 //arrays of strings 

 

        

  • 6
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值