例如我在CEdit输入序号:7 9 12,每个序号用空格隔开,然后读取数组中相应序号的值,该如何做?望高手指点

解决方案 »

  1.   

    GetWindowText();
    strtok();
    atoi();
      

  2.   

    输入的序号的数目知道不?
    知道的话就用sscanf来读。如3个数就:
    sscanf(stredit,"%d %d %d",&num1,&num2,&num3);
      

  3.   

    char *strtok(
       char *strToken,
       const char *strDelimit 
    );
      

  4.   

    CString str
    str.GetWindowText(num)
    然后就是对str进行分词:strtok
      

  5.   

    CStringArray arrTemp; CString strTemp;
            m_edit.GetWindowText(strTemp);
    char *ss=strTemp.GetBufferSetLength(strTemp.GetLength());  char *p;
    for ( p=strtok(ss, " "); p!=NULL; p=strtok(NULL, " ") ) { arrTemp.Add(p); }arrTemp[i] 为结果
      

  6.   

    在小三的基础上
    对每个arrTemp的值用atoi()转换一下
      

  7.   


    void spanText(char* pszText)
    {
    char* pTmpBuf = new char[strlen(pszText) + 1];
    char* pTmpIndex = pTmpBuf;
    char* pIndex = pszText; while (*pIndex != '\0'){
    while (((*pTmpIndex = *pIndex) != ' ') &&
       ((*pTmpIndex = *pIndex) != '\0')){
    pIndex ++;
    pTmpIndex ++;
    }
    *pTmpIndex = '\0'; int nTemp = atoi(pTmpBuf);
    pTmpIndex = pTmpBuf;
    cout << "Get integer value : " << nTemp << endl; while ((*pIndex == ' ') && (*pIndex != '\0')){
    pIndex ++;
    }
    } delete[] pTmpBuf;
    }