关于std::string.length() std::string.size()
来源:互联网 发布:北京网络经理薪资 编辑:程序博客网 时间:2024/06/05 09:33
eclipse的代码提示获取到的描述:
/// Returns the number of characters in the string, not including any
/// null-termination.
意思大概是返回字符串的字符个数,不包括结束符
我的系统的ubuntu13.04,系统设置的编码如下:
LANG=zh_CN.UTF-8
LANGUAGE=zh_CN:zh:en_US:en
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC=zh_CN.UTF-8
LC_TIME=zh_CN.UTF-8
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY=zh_CN.UTF-8
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER=zh_CN.UTF-8
LC_NAME=zh_CN.UTF-8
LC_ADDRESS=zh_CN.UTF-8
LC_TELEPHONE=zh_CN.UTF-8
LC_MEASUREMENT=zh_CN.UTF-8
LC_IDENTIFICATION=zh_CN.UTF-8
LC_ALL=
在此环境下执行下面的代码:
std::string str = "中国";
cout << str.size() << "," << str.length() << "," << strlen(str.c_str())<< endl;
结果为:
6,6,6
返回的其实是字节数
- 关于std::string.length() std::string.size()
- std::string 的length()与size()方法没有区别
- 关于using std::string
- std::string
- std::string
- std::string
- std::string
- std::string
- std::string
- std::string
- std::string
- std::string
- std - string
- std::string
- std::string
- std::string
- std::string
- std::string
- C# asp.net MVC 权限设计(续)
- Android使用Application总结
- android 通讯录的查看和添加
- javaweb jsp页面中实现文件下载
- .net 调用webservice 总结
- 关于std::string.length() std::string.size()
- 安装subclipse, MyEclipse10 SVN插件,link方法
- 如何解决c++中循环包含头文件的问题
- 黑马程序员_毕向东_Java基础视频教程学习笔记(七)
- MyEclipse下开发Web Service(Axis)
- 如何用git创建一个项目
- Jeecg 初级入门
- Java_SE培训笔记
- jsonp跨域请求