extract tokens from string in a loop return
program.c copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#include <stdio.h>
#include <string.h>
int
main()
{
char
string[] =
"A B C"
;
char
*stringp = string;
char
*delim =
" "
;
char
*token;
while
(stringp != NULL) {
token = strsep(&stringp, delim);
puts
(token);
}
return
0;
}
|
Output
1
2
3
|
A
B
C
|