Re: [NEWBIE] Find a chars name in a string

From: George (greerga@CIRCLEMUD.ORG)
Date: 01/05/98

On Sat, 3 Jan 1998, - Pure Krome - wrote:

>if i have some string (eg .. "hello everyone one. My name is
>DumbNewbie!"), what C function would return TRUE or whatever if i'm
>trying to test if string "DumbNewbie" - or for that matter, _any_ string
>- in some other string.

(May vary with OS)

       strstr - locate a substring

       #include <string.h>

       char *strstr(const char *haystack, const char *needle);

       The  strstr()  function  finds the first occurrence of the
       substring needle in the string haystack.  The  terminating
       `\0' characters are not compared.

       The  strstr()  function returns a pointer to the beginning
       of the substring, or NULL if the substring is not found.

       index(3),  memchr(3),  rindex(3),  strchr(3),  strpbrk(3),
       strsep(3), strspn(3), strtok(3)

char *where_is_it = strstr(string_given, "DumbNewbie");

George Greer  -   | Genius may have its limitations, but stupidity | is not thus handicapped. -- Elbert Hubbard

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

This archive was generated by hypermail 2b30 : 12/15/00 PST