关于std::string.length() std::string.size()
2013-11-15 10:55
260 查看
eclipse的代码提示获取到的描述:/// Returns the number of characters in the string, not including any/// null-termination.意思大概是返回字符串的字符个数,不包括结束符我的系统的ubuntu13.04,系统设置的编码如下:LANG=zh_CN.UTF-8LANGUAGE=zh_CN:zh:en_US:enLC_CTYPE="zh_CN.UTF-8"LC_NUMERIC=zh_CN.UTF-8LC_TIME=zh_CN.UTF-8LC_COLLATE="zh_CN.UTF-8"LC_MONETARY=zh_CN.UTF-8LC_MESSAGES="zh_CN.UTF-8"LC_PAPER=zh_CN.UTF-8LC_NAME=zh_CN.UTF-8LC_ADDRESS=zh_CN.UTF-8LC_TELEPHONE=zh_CN.UTF-8LC_MEASUREMENT=zh_CN.UTF-8LC_IDENTIFICATION=zh_CN.UTF-8LC_ALL=在此环境下执行下面的代码:std::string str = "中国";cout << str.size() << "," << str.length() << "," << strlen(str.c_str())<< endl;结果为:6,6,6返回的其实是字节数
相关文章推荐
- 2. std::string 的 size() length() capacity()
- std::string 的length()与size()方法没有区别
- 关于vector.size()和string.length() 的返回类型 size_type
- 关于StringBuffer.setLength和trimToSize
- No size set for variable length data type: String
- C/C++中关于std::string的compare陷阱示例详解
- 关于char[]数组,char*指针,std::string*之间的转化
- 关于string::size_type
- 关于string::size_type
- 关于std::stringsteam的clear与str方法
- WCF 配置文件中的MaxStringContentLength & MaxReceivedMessageSize
- 用C++的string::size()和string::length()返回值做比较
- 关于字符串指针初始化std::string的一个小问题
- 关于Qt内嵌CEF使用QString::toStdString();函数导致的一些坑
- #2334:Simple prefix compression--关于string.length()
- WCF 配置文件中的MaxStringContentLength & MaxReceivedMessageSize
- WCF - MaxStringContentLength & MaxReceivedMessageSize
- std::string的find返回值为string::size_type
- scala中为什么针对array和string的长度计算推荐size,而不是length
- 关于存储过程传出值"String[2]: Size 属性具有无效大小值 0,”