返回信息流☆─────────────────────────────────────☆
zgslovewy (畅想随行) 于 (Tue Apr 13 22:40:10 2010) 提到:
感谢大家的回帖 发现时自己的思路有问题 不过引起了一番讨论 越来越喜欢这个版了哈
☆─────────────────────────────────────☆
a206206 (每天都被人超级鄙视的寂寞帝和悲剧帝) 于 (Tue Apr 13 22:51:41 2010) 提到:
sizeof
☆─────────────────────────────────────☆
ericyosho (ericyosho) 于 (Wed Apr 14 00:28:37 2010) 提到:
求解,一个string的数组,你sizeof咋能知道里面具体有多少个字符串?
【 在 a206206 的大作中提到: 】
: sizeof
☆─────────────────────────────────────☆
newcomer (好好学习) 于 (Wed Apr 14 06:44:13 2010) 提到:
我用循环判断的
while(*(p_cp+i))
{
i++;
}
【 在 ericyosho 的大作中提到: 】
: 求解,一个string的数组,你sizeof咋能知道里面具体有多少个字符串?
☆─────────────────────────────────────☆
KevenStar (雨落星辰) 于 (Wed Apr 14 10:32:13 2010) 提到:
sizeof理论上可以 因为字符是占一个字节 用sizeof得到多少个字节 就知道多少个字符,但是不排除很特殊的情况。 比如字符里由汉字等
☆─────────────────────────────────────☆
h1048576 (h1048576) 于 (Wed Apr 14 11:26:47 2010) 提到:
sizeof(arr)/sizeof(arr[0])
☆─────────────────────────────────────☆
a206206 (每天都被人超级鄙视的寂寞帝和悲剧帝) 于 (Wed Apr 14 11:55:00 2010) 提到:
【 在 newcomer 的大作中提到: 】
: 我用循环判断的
: while(*(p_cp+i))
: {
: ...................
我试了一下,string n[2],cout<<n[2],结果电脑全面瘫痪了。。。
ps:永远不要试图引用你不确定是什么的东西
☆─────────────────────────────────────☆
zwp (Shawn Johnson) 于 (Wed Apr 14 12:00:17 2010) 提到:
有汉字就比较麻烦了。
☆─────────────────────────────────────☆
ericyosho (ericyosho) 于 (Wed Apr 14 12:55:29 2010) 提到:
和汉字有关系么?
☆─────────────────────────────────────☆
newcomer (好好学习) 于 (Wed Apr 14 13:53:15 2010) 提到:
嗯 我看错了
【 在 a206206 (每天都被人超级鄙视的寂寞帝和悲剧帝) 的大作中提到: 】
: 我试了一下,string n[2],cout<<n[2],结果电脑全面瘫痪了。。。
: ps:永远不要试图引用你不确定是什么的东西
☆─────────────────────────────────────☆
never115 (竹马) 于 (Wed Apr 14 14:10:16 2010) 提到:
这个问题相当于,有一个int数组,怎么知道里面有几个数?
比如int a[10],能够知道里面放了几个数?
LZ是这个意思吧?
☆─────────────────────────────────────☆
newcomer (好好学习) 于 (Wed Apr 14 14:36:17 2010) 提到:
我感觉lz也是这个意思
【 在 never115 (竹马) 的大作中提到: 】
: 这个问题相当于,有一个int数组,怎么知道里面有几个数?
: 比如int a[10],能够知道里面放了几个数?
: LZ是这个意思吧?
: ...................
☆─────────────────────────────────────☆
FadeToBlack (拜萝卜教 | [敏感词]NMB) 于 (Wed Apr 14 21:06:21 2010) 提到:
电脑全面瘫痪的定义是?
【 在 a206206 (每天都被人超级鄙视的寂寞帝和悲剧帝) 的大作中提到: 】
: 我试了一下,string n[2],cout<<n[2],结果电脑全面瘫痪了。。。
: ps:永远不要试图引用你不确定是什么的东西
☆─────────────────────────────────────☆
a206206 (每天都被人超级鄙视的寂寞帝和悲剧帝) 于 (Wed Apr 14 21:19:33 2010) 提到:
【 在 FadeToBlack 的大作中提到: 】
: 电脑全面瘫痪的定义是?
就是程序死循环,无限乱码,电脑卡死,连续的发出警铃声,就是那个\a,程序都崩掉了,不得不立即关机,好奇的话你可以试一下。我用的dev c++
☆─────────────────────────────────────☆
richlm (银剑山庄) 于 (Wed Apr 14 21:26:52 2010) 提到:
字符串的个数何来?我理解的string如下:
String objects are a special type of container, specifically designed to operate with sequences of characters.
Unlike traditional c-strings, which are mere sequences of characters in a memory array, C++ string objects belong to a class with many built-in features to operate with strings in a more intuitive way and with some additional useful features common to C++ containers.
【 在 zgslovewy 的大作中提到: 】
: 用数组名.length()不行啊。。
☆─────────────────────────────────────☆
wks (cloverprince) 于 (Wed Apr 14 22:23:51 2010) 提到:
那就数'\0'的个数呗。
☆─────────────────────────────────────☆
newcomer (好好学习) 于 (Wed Apr 14 23:25:11 2010) 提到:
re
【 在 wks (cloverprince) 的大作中提到: 】
: 那就数'\0'的个数呗。
☆─────────────────────────────────────☆
ericyosho (ericyosho) 于 (Thu Apr 15 09:46:12 2010) 提到:
你确定是char*数组么?
不是string对象的数组么
@@
这就体现
const int arraysize = 10;
string array[arraysize];
的好处了
【 在 wks 的大作中提到: 】
: 那就数'\0'的个数呗。
☆─────────────────────────────────────☆
jokerlee (Jackal The Dire) 于 (Thu Apr 15 09:52:42 2010) 提到:
LZ挖了个坑就跑了,string数组是啥,string? string[]? char[]? wchar_t[]?
☆─────────────────────────────────────☆
CLegend (皮波) 于 (Thu Apr 15 11:28:31 2010) 提到:
什么时候会用到计算string的个数呢?对于该数组赋值,那么每次赋值有一个计数,最后这个计数不就是数组元素个数吗?不解啊
☆─────────────────────────────────────☆
purevirtual (天之健|杨无敌|hf在我心) 于 (Thu Apr 15 12:00:57 2010) 提到:
为什么不用vector?然后直接size()
【 在 zgslovewy (畅想随行) 的大作中提到: 】
: 用数组名.length()不行啊。。
☆─────────────────────────────────────☆
shuimu1027 (水母倍儿不贫) 于 (Thu Apr 15 13:32:07 2010) 提到:
邹哥……sizeof
这是一条镜像帖。来源:北邮人论坛 / cpp / #38471同步于 2010/4/23
CPP机器人发帖
[合集] 一个string数组 用哪个函数可求数组中包含的字符串个数
jokerlee
2010/4/23镜像同步0 回复
订阅后,新回复会通过你的通知中心匿名送达。
0 条回复
暂无回复 · 你可以订阅本帖等待新回复。