CString::Find

intFind(TCHARch**)const;**

intFind(LPCTSTRlpszSub**)const;**

int Find( TCHAR ch**, int** nStart ) const;

int Find( LPCTSTR pstr**, int** nStart ) const;

Return Value

The 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.

Parameters

ch

A single character to search for.

lpszSub

A substring to search for.

nStart

The 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.

pstr

A pointer to a string to search for.

Remarks

Searches this string for the first match of a substring. The function is overloaded to accept both single characters (similar to the run-time function strchr) and strings (similar to strstr).

Example

// First example demonstrating
// CString::Find ( TCHAR ch )
CString s( "abcdef" );
ASSERT( s.Find( 'c' ) == 2 );
ASSERT( s.Find( "de" ) == 3 );

// Second example demonstrating
// CString::Find( TCHAR ch, int nStart )
CString str("The stars are aligned");
int n = str.Find('e', 5);
ASSERT(n == 12);

CString OverviewClass MembersHierarchy Chart

See Also   CString::ReverseFind, CString::FindOneOf