首页 > 编程语言 > 详细

C++之STL之string

时间:2016-10-16 14:04:31      阅读:142      评论:0      收藏:0      [点我收藏+]

/*C 语言中字符数组一般会采用char str[]来存放,但是显得会比较麻烦,C++在stl中加入
了string类型,对字符串常用的功能进行了封装,操作起来比较方便*/
#include<cstdio>
#include<string>
using namespace std;
int main(){
string str = "hello world";
for (int i = 0; i< str.length(); i++){
printf("%c",str[i]);
}
return 0;
}

输出结果如下:

hello world

C++之STL之string

原文:http://www.cnblogs.com/ylHe/p/5966370.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!