1.\" Copyright (c) 1990, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" Chris Torek and the American National Standards Committee X3, 6.\" on Information Processing Systems. 7.\" 8.\" Redistribution and use in source and binary forms, with or without 9.\" modification, are permitted provided that the following conditions 10.\" are met: 11.\" 1. Redistributions of source code must retain the above copyright 12.\" notice, this list of conditions and the following disclaimer. 13.\" 2. Redistributions in binary form must reproduce the above copyright 14.\" notice, this list of conditions and the following disclaimer in the 15.\" documentation and/or other materials provided with the distribution. 16.\" 3. Neither the name of the University nor the names of its contributors 17.\" may be used to endorse or promote products derived from this software 18.\" without specific prior written permission. 19.\" 20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" @(#)strchr.3 8.2 (Berkeley) 4/19/94 33.\" $FreeBSD: src/lib/libc/string/strchr.3,v 1.13 2007/01/09 00:28:12 imp Exp $ 34.\" 35.Dd March 3, 2013 36.Dt STRCHR 3 37.Os 38.Sh NAME 39.Nm strchr , 40.Nm strrchr , 41.Nm strrchrnul 42.Nd locate character in string 43.Sh LIBRARY 44.Lb libc 45.Sh SYNOPSIS 46.In string.h 47.Ft "char *" 48.Fn strchr "const char *s" "int c" 49.Ft "char *" 50.Fn strrchr "const char *s" "int c" 51.Ft "char *" 52.Fn strchrnul "const char *s" "int c" 53.Sh DESCRIPTION 54The 55.Fn strchr 56function locates the first occurrence of 57.Fa c 58(converted to a 59.Vt char ) 60in the string pointed to by 61.Fa s . 62The terminating nul character is considered part of the string; 63therefore if 64.Fa c 65is 66.Ql \e0 , 67the functions locate the terminating 68.Ql \e0 . 69.Pp 70The 71.Fn strrchr 72function is identical to 73.Fn strchr 74except it locates the last occurrence of 75.Fa c . 76.Pp 77The 78.Fn strchrnul 79function is identical to 80.Fn strchr 81except that it returns a pointer to the terminating nul character of 82.Fa s 83instead of 84.Dv NULL 85if 86.Fa c 87is not found. 88.Sh RETURN VALUES 89The functions 90.Fn strchr 91and 92.Fn strrchr 93return a pointer to the located character, or 94.Dv NULL 95if the character does not appear in the string. 96.Fn strchrnul 97returns a pointer to the located character, or to the terminating nul 98character of 99.Fa s 100if 101.Fa c 102is not found in the string. 103.Sh SEE ALSO 104.Xr memchr 3 , 105.Xr memmem 3 , 106.Xr strcspn 3 , 107.Xr strpbrk 3 , 108.Xr strsep 3 , 109.Xr strspn 3 , 110.Xr strstr 3 , 111.Xr strtok 3 112.Sh STANDARDS 113The functions 114.Fn strchr 115and 116.Fn strrchr 117conform to 118.St -isoC . 119.Pp 120The 121.Fn strchrnul 122function first appeared in glibc 2.1.1 123