首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

C++中将字符串转换为字符串数组,该如何解决

2012-02-27 
C++中将字符串转换为字符串数组比如CStringi see dead peole,将其转换为s[0]is[1]sees[2]deads[3]p

C++中将字符串转换为字符串数组
比如CString='i see dead peole',将其转换为
s[0]=i
s[1]=see
s[2]=dead
s[3]=people

[解决办法]
完蛋..

代码写错了..!

----


CString str = "Hello World";
CString ptr[100];
int i = 0;

while(TRUE)
{
int index = str.Find(' ');

if (index == -1)
{
ptr[i] = str;
break;
}

ptr[i] = str.Left(index);
str = str.Right(str.GetLength() - index - 1);
i++;
}

热点排行