1STRCHR(3)                  Linux Programmer's Manual                 STRCHR(3)
2
3
4

NAME

6       strchr, strrchr, strchrnul - locate character in string
7

SYNOPSIS

9       #include <string.h>
10
11       char *strchr(const char *s, int c);
12
13       char *strrchr(const char *s, int c);
14
15       #define _GNU_SOURCE         /* See feature_test_macros(7) */
16       #include <string.h>
17
18       char *strchrnul(const char *s, int c);
19

DESCRIPTION

21       The  strchr() function returns a pointer to the first occurrence of the
22       character c in the string s.
23
24       The strrchr() function returns a pointer to the last occurrence of  the
25       character c in the string s.
26
27       The strchrnul() function is like strchr() except that if c is not found
28       in s, then it returns a pointer to the null  byte  at  the  end  of  s,
29       rather than NULL.
30
31       Here "character" means "byte"; these functions do not work with wide or
32       multibyte characters.
33

RETURN VALUE

35       The strchr() and strrchr() functions return a pointer  to  the  matched
36       character  or NULL if the character is not found.  The terminating null
37       byte is considered part of the string, so that if  c  is  specified  as
38       '\0', these functions return a pointer to the terminator.
39
40       The strchrnul() function returns a pointer to the matched character, or
41       a pointer to the null byte at the end of s (i.e., s+strlen(s))  if  the
42       character is not found.
43

VERSIONS

45       strchrnul() first appeared in glibc in version 2.1.1.
46

CONFORMING TO

48       strchr() and strrchr() are in SVr4, 4.3BSD, C89, C99.  strchrnul() is a
49       GNU extension.
50

SEE ALSO

52       index(3),  memchr(3),  rindex(3),  string(3),  strlen(3),   strpbrk(3),
53       strsep(3), strspn(3), strstr(3), strtok(3), wcschr(3), wcsrchr(3)
54

COLOPHON

56       This  page  is  part of release 3.53 of the Linux man-pages project.  A
57       description of the project, and information about reporting  bugs,  can
58       be found at http://www.kernel.org/doc/man-pages/.
59
60
61
62GNU                               2012-04-24                         STRCHR(3)
Impressum