运用函数AfxExtractSubString可以解决.
BOOL AfxExtractSubString(CString& rString, LPCTSTR lpszFullString,int iSubString, TCHAR chSep = '\n') 参数说明: rString 得到的字符串;lpszFullString 待分割的字符串;iSubString 要得到第几个字符串;chSep 个子串之间的分隔符,默认是回车;
举例:
//实现的功能是把m_day1中的数字存放到字符串数组str中.
CString m_day1=”2009/11/07-12:12:12”;
CString tempstr1,tempstr2,tempstr3;
CString str[6];
for(int i=0;i<3;i++)
{
AfxExtractSubString(tempstr1,m_day1,i,'/');
str[i]=tempstr1;
}//tempstr1=="07-12:12:12"
for(i=0;i<2;i++)
{
AfxExtractSubString(tempstr2,tempstr1,i,'-');
str[i+2]=tempstr2;
}//tempstr2=="12:12:12"
for(i=0;i<3;i++)
{
AfxExtractSubString(tempstr3,tempstr2,i,':');
str[i+3]=tempstr3;
}
//如果要把字符串数组变为整型数组只要使用int atoi(const char*)函数即可.
函数AfxExtractSubString但是有两个限制: 1.仅仅能在MFC下使用的函数 2.分隔只能使用字符,不能使用字符串。

解决方案 »

  1.   

    你试试这些吧
    atof(将字符串转换成浮点型数)  
    相关函数  atoi,atol,strtod,strtol,strtoulsuch as: CString   strTemp="100";   
            int   i=0;     
        
            i=atoi(strTemp);   
            if(i   ==   100)     printf("ok:i=100");   
          
          run   result:   
              ok:i=100   我也是正在学习的哦
      

  2.   

    CString test;
    test="1234";
    char buff[10];
    atoi(test,buff,10);
    pritf("%d",buff);
      

  3.   

    MSDN的例子
    Example/* ATOF.C: This program shows how numbers stored
     * as strings can be converted to numeric values
     * using the atof, atoi, and atol functions.
     */#include <stdlib.h>
    #include <stdio.h>void main( void )
    {
       char *s; double x; int i; long l;   s = "  -2309.12E-15";    /* Test of atof */
       x = atof( s );
       printf( "atof test: ASCII string: %s\tfloat:  %e\n", s, x );   s = "7.8912654773d210";  /* Test of atof */
       x = atof( s );
       printf( "atof test: ASCII string: %s\tfloat:  %e\n", s, x );   s = "  -9885 pigs";      /* Test of atoi */
       i = atoi( s );
       printf( "atoi test: ASCII string: %s\t\tinteger: %d\n", s, i );   s = "98854 dollars";     /* Test of atol */
       l = atol( s );
       printf( "atol test: ASCII string: %s\t\tlong: %ld\n", s, l );
    }
    Outputatof test: ASCII string:   -2309.12E-15   float:  -2.309120e-012
    atof test: ASCII string: 7.8912654773d210   float:  7.891265e+210
    atoi test: ASCII string:   -9885 pigs      integer: -9885
    atol test: ASCII string: 98854 dollars      long: 98854
      

  4.   

    还可以用:
    sscanf();
    逆向用sprintf();
      

  5.   

    楼主你是觉得AfxExtractSubString()不好用么,我建议你使用CString类的Find()函数和Left()和right()函数就完全可以使用,并且也是可以查找字符串的,关于数字的转化函数用atoi()也可以了