aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/string/strsep.3
diff options
context:
space:
mode:
authorPawel Jakub Dawidek <pjd@FreeBSD.org>2008-12-05 15:50:59 +0000
committerPawel Jakub Dawidek <pjd@FreeBSD.org>2008-12-05 15:50:59 +0000
commit3027fbe00bda3964010e3ff19cafd1cf517fb9f9 (patch)
tree66977b802882ae074f036de4961550da199aa9e5 /lib/libc/string/strsep.3
parentb09d6bf32549c7967604806318d002e3a08b321c (diff)
downloadsrc-3027fbe00bda3964010e3ff19cafd1cf517fb9f9.tar.gz
src-3027fbe00bda3964010e3ff19cafd1cf517fb9f9.zip
Add an easier example.
Reviewed by: trasz
Notes
Notes: svn path=/head/; revision=185641
Diffstat (limited to 'lib/libc/string/strsep.3')
-rw-r--r--lib/libc/string/strsep.317
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/libc/string/strsep.3 b/lib/libc/string/strsep.3
index 919ea3c3f71b..9432a88380bd 100644
--- a/lib/libc/string/strsep.3
+++ b/lib/libc/string/strsep.3
@@ -31,7 +31,7 @@
.\" @(#)strsep.3 8.1 (Berkeley) 6/9/93
.\" $FreeBSD$
.\"
-.Dd June 9, 1993
+.Dd December 5, 2008
.Dt STRSEP 3
.Os
.Sh NAME
@@ -81,6 +81,21 @@ returns
.Sh EXAMPLES
The following uses
.Fn strsep
+to parse a string, and prints each token in separate line:
+.Bd -literal -offset indent
+char *token, *string, *tofree;
+
+tofree = string = strdup("abc,def,ghi");
+assert(string != NULL);
+
+while ((token = strsep(&string, ",")) != NULL)
+ printf("%s\en", token);
+
+free(tofree);
+.Ed
+.Pp
+The following uses
+.Fn strsep
to parse a string, containing tokens delimited by white space, into an
argument vector:
.Bd -literal -offset indent