请问,如果想去掉一个字符串的前面几个和最后几个该怎么办?比如":10000000DF00DF01DF01DF01DF01DF01DF010100D0"
我想得到中间的"DF00DF01DF01DF01DF01DF01DF010100",去掉了前面的9个和后面的2个

解决方案 »

  1.   

    可以使用CString的Mid函数啊。随便取第几个到第几个
      

  2.   

    或者使用Left和right去头去尾。
    CString str = ":10000000DF00DF01DF01DF01DF01DF01DF010100D0";
    str = str.Mid(9,str.GetLength()-9);
    str = str.Left(str.GetLength() - 2);
      

  3.   

    是否去掉的数目都是确定的,如果是或者即使不是但有方法可以算出,都好办
    CString Left( int nCount ) const;
    throw( CMemoryException );
    CString Right( int nCount ) const;
    throw( CMemoryException );
    或者
    CString Mid( int nFirst, int nCount ) const;
    throw( CMemoryException );
      

  4.   

    如果前后去掉的数目是确定的或者可以算出的都好办
    Right和Left
    或者Mid
    都是CString的函数,查下MSDN
      

  5.   

    使用Mid、Left、Right可随心所欲取字符串中的一部分。