Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 5 Dec 2008 15:50:59 +0000 (UTC)
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r185641 - head/lib/libc/string
Message-ID:  <200812051550.mB5FoxGg062499@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pjd
Date: Fri Dec  5 15:50:59 2008
New Revision: 185641
URL: http://svn.freebsd.org/changeset/base/185641

Log:
  Add an easier example.
  
  Reviewed by:	trasz

Modified:
  head/lib/libc/string/strsep.3

Modified: head/lib/libc/string/strsep.3
==============================================================================
--- head/lib/libc/string/strsep.3	Fri Dec  5 15:31:51 2008	(r185640)
+++ head/lib/libc/string/strsep.3	Fri Dec  5 15:50:59 2008	(r185641)
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812051550.mB5FoxGg062499>