HELPLIB.HLB  —  CRTL  strstr
    Locates the first occurrence in the string pointed to by s1 of
    the sequence of characters in the string pointed to by s2.

    Format

      #include  <string.h>

      char *strstr  (const char *s1, const char *s2);

1  –  Function Variants

    The strstr function has variants named _strstr32 and _strstr64
    for use with 32-bit and 64-bit pointer sizes, respectively.

2  –  Arguments

 s1, s2

    Pointers to character strings.

3  –  Return Values

    Pointer            A pointer to the located string.
    NULL               Indicates that the string was not found.

4  –  Example

        #include <stdlib.h>
        #include <stdio.h>
        #include <string.h>

        main()
        {
            static char lookin[]="that this is a test was at the end";

            putchar('\n');
            printf("String: %s\n", &lookin[0] );
            putchar('\n');
            printf("Addr: %s\n", &lookin[0] );
            printf("this: %s\n", strstr( &lookin[0] ,"this") );
            printf("that: %s\n", strstr( &lookin[0] , "that" ) );
            printf("NULL: %s\n", strstr( &lookin[0], "" ) );
            printf("was: %s\n", strstr( &lookin[0], "was" ) );
            printf("at: %s\n", strstr( &lookin[0], "at" ) );
            printf("the end: %s\n", strstr( &lookin[0], "the end") );
            putchar('\n');

            exit(0);
        }

    This example produces the following results:

    $ RUN STRSTR_EXAMPLE
    String: that this is a test was at the end
    Addr: that this is a test was at the end
    this: this is a test was at the end
    that: that this is a test was at the end
    NULL: that this is a test was at the end
    was: was at the end
    at: at this is a test was at the end
    the end: the end
    $
Close Help