使用字符串搜索函数,找到空格位置,然后使用取字串函数
int Find(
   PCXSTR pszSub,
   int iStart=0);

解决方案 »

  1.   

    CString str,strLeft,strRight;
    str="1001 AAAAA";
    int nSlash=str.Find(" ");
    if(nSlash!=-1)
    {
       strLeft=str.Left(nSlash);
       strRight=str.Right(nSlash+1);
    }
      

  2.   

    哦,不好意思,写错了应该是  strRight=str.Mid(nSlash+1);
    这样
    CString str,strLeft,strRight;
    str="1001 AAAAA";
    int nSlash=str.Find(" ");
    if(nSlash!=-1)
    {
       strLeft=str.Left(nSlash);
       strRight=str.MId(nSlash+1);
    }
      

  3.   

    CString strItem="1001  AAAAA";
    CString arrItem[2];
    int i=strItem.Find(' ');
    arrItem[0]=strItem.Left(i);
    arrItem[1]=strItem.Right(i+1);
      

  4.   

    exmaple:CString m_str="aa  bb  cc  dd ee" 
    int strName_length=m_str.GetLength();
    int position1=PT_Table.m_strName.Find('  ');
    if(position1!=-1)
    {
    int position2=m_str.Find('  ',position1+1);
    int position3=m_str.Find('  ',position2+1);
    int position4=m_strName.Find('  ',position3+1);
    CString str1,str2,str3,str4,str5;
    str1=m_str.Left(position1);
    str2=m_str.Mid(position1+1,position2-position1-1);
    str3=m_str.Mid(position2+1,position3-position2-1);
    str4=m_str.Mid(position3+1,position4-position3-1);
    str5=m_strRight(strName_length-position4-1);
    then U CAN CONVERT CSTRING TO CHAR*
      

  5.   

    sorry.
    maybe +2 not +1
    maybe something wrong with +1 and -1.u try it.
      

  6.   

    哈哈,就是VB中的split函数!我记得在哪儿见过,不过找不到了,自己写吧
      

  7.   

    there maybe something wrong with +1 -1,maybe +2,-2?i haven't practiced  by myself.
      

  8.   

    如果你用MFC的话,
    在msdn中仔细的将CString类的函数看一遍,包你会做了
      

  9.   

    #include <iostream>
    #include <strstream>
    using namespace std;int main() {
      istrstream s("1001 AAAAA");
      char a[20],b[20];
      s >> a >> b; // Whitespace-delimited input
      cout << " s1 = " << a << endl;
      cout << " s2 = " << b << endl;  return 0;大家认为这样写可以吗?