VC字符串截取
答案:2 悬赏:20 手机版
解决时间 2021-03-07 15:04
- 提问者网友:酱爆肉
- 2021-03-07 07:11
VC字符串截取
最佳答案
- 五星知识达人网友:掌灯师
- 2021-03-07 08:24
楼上的办法是可以
不过麻烦了些
只要这样就行了 .
CString str ; //这是源
char* pStr = new char[ str.GetLength() + 1 ] ;
pStr = str.GetBuffer() ;
此时 pStr就指向了str 的首地址
下面用一个循环就能得到各个 字符了
for( int i = 0 ; i< str.GetLength() ; i++)
pStr[i] ; //pStr[i],就是各个字符了把这个放到你想放的数组中去
不过麻烦了些
只要这样就行了 .
CString str ; //这是源
char* pStr = new char[ str.GetLength() + 1 ] ;
pStr = str.GetBuffer() ;
此时 pStr就指向了str 的首地址
下面用一个循环就能得到各个 字符了
for( int i = 0 ; i< str.GetLength() ; i++)
pStr[i] ; //pStr[i],就是各个字符了把这个放到你想放的数组中去
全部回答
- 1楼网友:孤老序
- 2021-03-07 09:53
int pos = str.Find("&");
CString msg = str.Left(pos);
str = str.Right(str.GetLength() - pos -1 );
pos = str.Find("&");
CString datatime = str.Left(pos);
str = str.Right(str.GetLength() - pos -1 );
pos = str.Find("&");
CString username = str.Left(pos);
str = str.Right(str.GetLength() - pos -1 );
pos = str.Find("&");
CString group = str.Left(pos);
str = str.Right(str.GetLength() - pos -1 );
CString message = str.Left(pos);
CString year = datatime.Left(4);
datatime = datatime.Right(datatime.GetLength() - 4);
CString month = datatime.Left(2);
datatime = datatime.Right(datatime.GetLength() - 2);
CString day = datatime.Left(2);
datatime = datatime.Right(datatime.GetLength() - 2);
CString hour = datatime.Left(2);
datatime = datatime.Right(datatime.GetLength() - 2);
CString minute = datatime.Left(2);
datatime = datatime.Right(datatime.GetLength() - 2);
CString second = datatime.Left(2);
datatime = year+"/"+month+"/"+day+" "+hour+":"+minute+":"+second;
上面是字符串截取的例子,你可以研究研究。
CString msg = str.Left(pos);
str = str.Right(str.GetLength() - pos -1 );
pos = str.Find("&");
CString datatime = str.Left(pos);
str = str.Right(str.GetLength() - pos -1 );
pos = str.Find("&");
CString username = str.Left(pos);
str = str.Right(str.GetLength() - pos -1 );
pos = str.Find("&");
CString group = str.Left(pos);
str = str.Right(str.GetLength() - pos -1 );
CString message = str.Left(pos);
CString year = datatime.Left(4);
datatime = datatime.Right(datatime.GetLength() - 4);
CString month = datatime.Left(2);
datatime = datatime.Right(datatime.GetLength() - 2);
CString day = datatime.Left(2);
datatime = datatime.Right(datatime.GetLength() - 2);
CString hour = datatime.Left(2);
datatime = datatime.Right(datatime.GetLength() - 2);
CString minute = datatime.Left(2);
datatime = datatime.Right(datatime.GetLength() - 2);
CString second = datatime.Left(2);
datatime = year+"/"+month+"/"+day+" "+hour+":"+minute+":"+second;
上面是字符串截取的例子,你可以研究研究。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯