目的是从下列字符串提取出IP和端口号
CString temp="227 Entering passive mode <172,18,16,176,229,252>";
void CmfcTestDlg::OnBnClickedOk()
{// TODO: 在此添加控件通知处理程序代码
CString temp="227 Entering passive mode <172,18,16,176,229,252>";
int base=temp.Find('<');
int top=temp.Find('>');
str=temp.Mid(base+1,top-base-1);
//MessageBox(str);
base=0;
top=str.GetLength()-1;
int index;
CString store[6];
int i=0;
while(true)
{
index=str.Find(',');
//如果找不到,返回值是-1,又在此浪费了许多时间
if(-1==index)
{
break;
}
base=0;
store[i]=str.Mid(base,index-base);
MessageBox(store[i]);
i++;
top=str.GetLength()-1;
str=str.Right(top-index);
}
store[i]=str;
MessageBox(store[i]);
CDialogEx::OnOK();
}