我想是将字符串中的字符分割后,从第二个开始将分割后的字符串存储到数组中.
我的代码是:
  CString m="23 43 45 56"
  int i = 0;
  double s100];
  char *token = NULL;
  char *step = " ";
  token = strtok((char*)(const char*)m, step);
  while (token!=NULL)
  {
      s[i]=atof(token);  //将分割后的字符串存储起来
       token = strtok(NULL, step);
   }
我想数据从43开始存储到数组里.该如何实现.

解决方案 »

  1.   

    int j=0;
    while (token!=NULL)
    {
    j++;
    if (1==j)
      continue;
     ...
    }
      

  2.   

    CString m="23 43 45 56"
      int i = 0;
      double s100];
      char *token = NULL;
      char *step = " ";
      token = strtok((char*)(const char*)m, step);
      token = strtok(NULL, step);  //再分割一次
      while (token!=NULL)
      {
          s[i]=atof(token);  //将分割后的字符串存储起来
           token = strtok(NULL, step);
       }
      

  3.   

    勘误CString strLine="12 34 56 78";       
    char *ss=strLine.GetBufferSetLength(strLine.GetLength());
    strLine.ReleaseBuffer(); 
    char *p;
    CStringArray strArray;
    for ( p=strtok(ss, " "); p!=NULL; p=strtok(NULL, " ") )
    {
    strArray.Add(p);
    }
    strArray.RemoveAt(0);
      

  4.   

    满足你的要求: CString m="23 43 45 56";
    double s[3];
    CString n;
    int nPos = 0;
    for(int i=2; i>=0; i--)
    {
    nPos = m.ReverseFind(' ');
    n = m.Right(m.GetLength()-nPos-1);
    s[i] = atof(n);
    m.SetAt(nPos,'\0');
    }
      

  5.   

    lixiaosan(小三) :
    CString strLine="12 34 56 78";
     如何写从分割的字符串中从后向前查找3个,即查找到34时。将43插入到数组s[0]中,56插入到s[1];