summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAaron Campbell <aaron@cvs.openbsd.org>1999-06-04 17:26:28 +0000
committerAaron Campbell <aaron@cvs.openbsd.org>1999-06-04 17:26:28 +0000
commite288cb3c3b2f3f37b0ec44648cf15b3ce1fa3299 (patch)
tree12e9837baab17044dfb4a12a684200874d8b0753 /lib
parent412c3d0b9e6062701f380fbd8e2f948eb3b5bf1b (diff)
add examples
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/string/strchr.332
-rw-r--r--lib/libc/string/strrchr.331
2 files changed, 40 insertions, 23 deletions
diff --git a/lib/libc/string/strchr.3 b/lib/libc/string/strchr.3
index c3bc2f88174..f4b4aef9760 100644
--- a/lib/libc/string/strchr.3
+++ b/lib/libc/string/strchr.3
@@ -33,14 +33,14 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $OpenBSD: strchr.3,v 1.3 1997/12/29 22:31:50 deraadt Exp $
+.\" $OpenBSD: strchr.3,v 1.4 1999/06/04 17:26:26 aaron Exp $
.\"
.Dd June 29, 1991
.Dt STRCHR 3
.Os
.Sh NAME
.Nm strchr
-.Nd locate character in string
+.Nd locate first occurence of a character in a string
.Sh SYNOPSIS
.Fd #include <string.h>
.Ft char *
@@ -48,13 +48,11 @@
.Sh DESCRIPTION
The
.Fn strchr
-function locates the first occurrence of
-.Ar c
-in the string pointed to by
-.Ar s .
-The terminating
-.Dv NUL
-character is considered part of the string.
+function locates the first occurrence of the character
+.Fa c
+in the string
+.Fa s .
+The terminating NUL character is considered part of the string.
If
.Fa c
is
@@ -63,11 +61,23 @@ is
locates the terminating
.Ql \e0 .
.Sh RETURN VALUES
-The function
+The
.Fn strchr
-returns a pointer to the located character, or
+function returns a pointer to the located character or
.Dv NULL
if the character does not appear in the string.
+.Sh EXAMPLES
+After the following call to
+.Fn strchr ,
+.Va p
+will point to the string
+.Qq oobar :
+.Bd -literal -offset indent
+char *p;
+char *s = "foobar";
+
+p = strchr(s, 'o');
+.Ed
.Sh SEE ALSO
.Xr index 3 ,
.Xr memchr 3 ,
diff --git a/lib/libc/string/strrchr.3 b/lib/libc/string/strrchr.3
index 6dd00d32fb4..4494728bdde 100644
--- a/lib/libc/string/strrchr.3
+++ b/lib/libc/string/strrchr.3
@@ -33,14 +33,14 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $OpenBSD: strrchr.3,v 1.2 1996/08/19 08:34:23 tholo Exp $
+.\" $OpenBSD: strrchr.3,v 1.3 1999/06/04 17:26:27 aaron Exp $
.\"
.Dd June 29, 1991
.Dt STRRCHR 3
.Os
.Sh NAME
.Nm strrchr
-.Nd locate character in string
+.Nd locate last occurence of a character in a string
.Sh SYNOPSIS
.Fd #include <string.h>
.Ft char *
@@ -48,12 +48,11 @@
.Sh DESCRIPTION
The
.Fn strrchr
-function
-locates the last occurrence of
+function locates the last occurrence of the character
.Fa c
-(converted to a char)
in the string
.Fa s .
+The terminating NUL character is considered part of the string.
If
.Fa c
is
@@ -64,13 +63,21 @@ locates the terminating
.Sh RETURN VALUES
The
.Fn strrchr
-function
-returns a pointer to the character,
-or a null
-pointer if
-.Fa c
-does not occur anywhere in
-.Fa s .
+function returns a pointer to the located character or
+.Dv NULL
+if the character does not appear in the string.
+.Sh EXAMPLES
+After the following call to
+.Fn strrchr ,
+.Va p
+will point to the string
+.Qq obar :
+.Bd -literal -offset indent
+char *p;
+char *s = "foobar";
+
+p = strrchr(s, 'o');
+.Ed
.Sh SEE ALSO
.Xr index 3 ,
.Xr memchr 3 ,