我想要的效果是这样的但是我现在是这样的我想要把7E作为分隔符把他们分隔出来,但是我现在分隔以后不会显示7E,求大神帮我看看。代码如下
void CTest3Dlg::OnRead()
{
// TODO: Add your control notification handler code here
UpdateData(); //将界面的数据更新到对应的变量中
char* buf;
CString str;
GetDlgItem(IDC_EDIT1)-> GetWindowText(str); //读取码流到str字符串中
str.Replace(_T("7E"),_T("H")); //将码流字符串中的7E替换为H
buf= new char[str.GetLength()+1]; //将char*转换为buf[]
memset(buf, 0, str.GetLength()+1); //buf[]初始化
strcpy(buf, str); //buf[]赋值
CString StrNum; // 列表控件的行标
CString strItem; //向控件中插入的字符串内容
int i=1;
char *seps="H"; //分隔符'H'
char *token=NULL;
token=strtok(buf,seps); //以'H'为分隔符分割字符串buf
while(token!=NULL)
{
strItem.Format ("%s%s%s","7E,token,7E");
token=strtok(NULL,seps);
StrNum.Format(_T("%d"),i++); //将整形变量i以字符型输出
int count=m_list.GetItemCount(); //获取列表控件当前存在的数据总量
m_list.InsertItem(count,StrNum); //插入一行
m_list.SetItemText(count,1,token); //为第一列插入字符串
}
}