strtok.3 (42869) | strtok.3 (44306) |
---|---|
1.\" Copyright (c) 1998 Softweyr LLC. All rights reserved. 2.\" 3.\" strtok_r, from Berkeley strtok 4.\" Oct 13, 1998 by Wes Peters <wes@softweyr.com> 5.\" 6.\" Copyright (c) 1988, 1991, 1993 7.\" The Regents of the University of California. All rights reserved. 8.\" --- 97 unchanged lines hidden (view full) --- 106character. 107When no more tokens remain, a null pointer is returned. 108.Sh EXAMPLE 109The following uses 110.Fn strtok_r () 111to parse two strings using separate contexts: 112.Bd -literal 113char test[80], blah[80]; | 1.\" Copyright (c) 1998 Softweyr LLC. All rights reserved. 2.\" 3.\" strtok_r, from Berkeley strtok 4.\" Oct 13, 1998 by Wes Peters <wes@softweyr.com> 5.\" 6.\" Copyright (c) 1988, 1991, 1993 7.\" The Regents of the University of California. All rights reserved. 8.\" --- 97 unchanged lines hidden (view full) --- 106character. 107When no more tokens remain, a null pointer is returned. 108.Sh EXAMPLE 109The following uses 110.Fn strtok_r () 111to parse two strings using separate contexts: 112.Bd -literal 113char test[80], blah[80]; |
114char *sep = "\\/:;=-"; | 114char *sep = "\e\e/:;=-"; |
115char *word, *phrase, *brkt, *brkb; 116 | 115char *word, *phrase, *brkt, *brkb; 116 |
117strcpy(test, "This;is.a:test:of=the/string\\tokenizer-function."); | 117strcpy(test, "This;is.a:test:of=the/string\e\etokenizer-function."); |
118 119for (word = strtok_r(test, sep, &brkt); 120 word; 121 word = strtok_r(NULL, sep, &brkt)) 122{ 123 strcpy(blah, "blah:blat:blab:blag"); 124 125 for (phrase = strtok_r(blah, sep, &brkb); 126 phrase; 127 phrase = strtok_r(NULL, sep, &brkb)) 128 { | 118 119for (word = strtok_r(test, sep, &brkt); 120 word; 121 word = strtok_r(NULL, sep, &brkt)) 122{ 123 strcpy(blah, "blah:blat:blab:blag"); 124 125 for (phrase = strtok_r(blah, sep, &brkb); 126 phrase; 127 phrase = strtok_r(NULL, sep, &brkb)) 128 { |
129 printf("So far we're at %s:%s\n", word, phrase); | 129 printf("So far we're at %s:%s\en", word, phrase); |
130 } 131} 132.Ed 133.Sh SEE ALSO 134.Xr index 3 , 135.Xr memchr 3 , 136.Xr rindex 3 , 137.Xr strchr 3 , --- 30 unchanged lines hidden --- | 130 } 131} 132.Ed 133.Sh SEE ALSO 134.Xr index 3 , 135.Xr memchr 3 , 136.Xr rindex 3 , 137.Xr strchr 3 , --- 30 unchanged lines hidden --- |