Browse Source

correct example

OPENBSD_2_7
deraadt 25 years ago
parent
commit
3369ca98b5
1 changed files with 6 additions and 5 deletions
  1. +6
    -5
      src/lib/libc/string/strtok.3

+ 6
- 5
src/lib/libc/string/strtok.3 View File

@ -33,7 +33,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: strtok.3,v 1.11 2000/04/21 15:24:20 aaron Exp $
.\" $OpenBSD: strtok.3,v 1.12 2000/04/24 16:55:44 deraadt Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt STRTOK 3 .Dt STRTOK 3
@ -107,11 +107,12 @@ int i = 0;
snprintf(s, sizeof(s), "cat dog horse cow"); snprintf(s, sizeof(s), "cat dog horse cow");
for ((p = strtok_r(s, " ", &last)); p; (p = strtok_r(NULL, " ", &last)), i++) {
if (i < MAXTOKENS - 1)
tokens[i] = p;
for ((p = strtok_r(s, " ", &last)); p;
(p = strtok_r(NULL, " ", &last)), i++) {
if (i < MAXTOKENS - 1)
tokens[i] = p;
} }
tokens[i] = '\e0';
tokens[i] = NULL;
.Ed .Ed
.Pp .Pp
That is, That is,


Loading…
Cancel
Save