请高手指教:
我想在一个字符串中查找一个子串,是否有现成的函数
最好字符串是用CString定义的

解决方案 »

  1.   

    CString::Find 
    int Find( TCHAR ch ) const;int Find( LPCTSTR lpszSub ) const;int Find( TCHAR ch, int nStart ) const;int Find( LPCTSTR pstr, int nStart ) const;Return ValueThe zero-based index of the first character in this CString object that matches the requested substring or characters; -1 if the substring or character is not found.ParameterschA single character to search for.lpszSubA substring to search for.nStartThe index of the character in the string to begin the search with, or 0 to start from the beginning. The character at nStart is excluded from the search if nStart is not equal to 0.pstrA pointer to a string to search for.
      

  2.   

    楼上的各位已经说得很清楚了,竟然是用CString类的话,其成员Find()就完全能满足你的要求!!!
      

  3.   

    CString::Find();    //finds a charactor or substring inside a larger string.orstrstr();
      

  4.   

    CString::Find
    MSDN里有详细的解释