VC字符串截取
来源:百度知道 编辑:UC知道 时间:2024/05/15 04:11:46
2.如何获取文本文件中内容存入数组。
楼上的办法是可以
不过麻烦了些
只要这样就行了 .
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],就是各个字符了把这个放到你想放的数组中去
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)