STL basic_string, string, wstring

basic_string也是一个STL中的sequence container, 但是多了些针对字符串处理的方法(分析针对MS STL)
append
c_str
compare
copy
data
find_first_not_of
find_first_of
find_last_not_of
find_last_of
length
replace
substr
其中以data()和c_str()特别有意思,data()就是调用c_str(),但是msdn又说data()返回的字符串没有'/0', 和代码冲突了,调试结果是有的

compare()也有点意思,修改了自身,然后还返回自身的引用(return *this), 返回值代表表达式的值,可以直接用于表达式使用

 

typedef basic_string<char, char_traits<char>, allocator<char> >
 string;
typedef basic_string<wchar_t, char_traits<wchar_t>,
 allocator<wchar_t> > wstring;
所以string和wstring就没有特别之处了

 

测试代码

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值