[Previous]
[Contents]
[Next]

strchr(), _fstrchr()

locate the first occurrence of a given character in a string

Synopsis:

#include <string.h>

char *strchr( const char *s, int c );
char __far *_fstrchr( const char __far *s, int c );

Description:

The strchr() function locates the first occurrence of c (converted to a char) in the string pointed to by s. The terminating null character is considered to be part of the string.

The _fstrchr() function is a data-model-independent form of the strchr() function. It accepts far pointer arguments, and returns a far pointer. It's useful in mixed memory model applications.

Returns:

A pointer to the located character, or NULL if the character does not occur in the string.

Examples:

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

void main()
  {
    char buffer[80];
    char *where;

    strcpy( buffer, "video x-rays" );
    where = strchr( buffer, 'x' );
    if( where == NULL ) {
      printf( "'x' not found\n" );
    }
  }

Classification:

strchr() is ANSI; _fstrchr() is WATCOM.

Safety:
Interrupt handler Yes
Signal handler Yes
Thread Yes

See also:

memchr(), strcspn(), strrchr(), strspn(), strstr(), strtok()


[Previous]
[Contents]
[Next]