08. august 2002 - 10:21Der er
3 kommentarer og 1 løsning
find alle ord i en tekst linie
Jeg vil gerne finde alle forekomster af bestemte ord (i første omgang bare ét ord) både med hesnyn til position i teksten og hvor mange forekomster der er i alt (pr. linie) disse oplysninger skal gemmes og sendes til den funktion der kalder søgerutinen...
Hvordan gøres det? kan jeg bruge strstr(...)? eller er der andre forslag...
Efter ti år i London, Madrid, Paris og Utrecht kommer Sabios AI-fokuserede program af arrangementer om kundeoplevelser, ‘Disrupt’, for første gang til Danmark.
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 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).
// Second example demonstrating // CString::Find( TCHAR ch, int nStart ) CString str("The stars are aligned"); int n = str.Find('e', 5); ASSERT(n == 12);
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.