Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

index(3)

rindex(3)

strcat(3)

strcmp(3)

strcspn(3)

strcpy(3)

strlen(3)

strncat(3)

strncmp(3)

strncpy(3)

strpbrk(3)

strrchr(3)

strspn(3)



  strchr(3)                           CLIX                           strchr(3)



  NAME

    strchr - Locates the first occurrence of a character in a string

  LIBRARY

    The Standard C Library (libc.a)

  SYNOPSIS

    #include <string.h>

    char *strchr(
      char * string ,
      int character );

  PARAMETERS

    string A pointer to a character string

    character
           A character

  DESCRIPTION

    The strchr() function returns a pointer to the first occurrence of the
    value specified by the character parameter in the string pointed to by the
    string parameter, or a NULL pointer if the character does not occur in the
    string.  The terminating null character is treated as part of the string
    pointed to by the string parameter.

  EXAMPLES

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

    main()
    {
         int comma;
         char *string;
         char *comma_ptr;

         string = "abc, def, hello";
         comma = (int)`,';

         /* This call will return a pointer to the first comma in `string' */
         comma_ptr = strchr(string, comma);

         if (! comma_ptr)
              printf("There is no comma in the string %s\n", string);
         else



  2/94 - Intergraph Corporation                                              1






  strchr(3)                           CLIX                           strchr(3)



              printf("The substring which begins with the first comma is %s\n",
                     comma_ptr);

    }


  RELATED INFORMATION

    Functions: index(3), rindex(3), strcat(3), strcmp(3), strcspn(3),
    strcpy(3), strlen(3), strncat(3), strncmp(3), strncpy(3), strpbrk(3),
    strrchr(3), strspn(3)











































  2                                              Intergraph Corporation - 2/94




Typewritten Software • bear@typewritten.org • Edmonds, WA 98026