Let's parse.
This commit is contained in:
parent
e32d1d22e6
commit
b8b37af1a4
|
|
@ -1 +1,2 @@
|
||||||
joy
|
joy
|
||||||
|
parser
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
const char *text = "hi there friend";
|
||||||
|
/* 01234567890123456789
|
||||||
|
^ ^
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
char *rest;
|
||||||
|
ptrdiff_t diff;
|
||||||
|
|
||||||
|
rest = strpbrk(text, " []");
|
||||||
|
while (NULL != rest) {
|
||||||
|
diff = rest - text;
|
||||||
|
text = rest;
|
||||||
|
printf("%ld\n", diff);
|
||||||
|
rest = strpbrk(++rest, " []");
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue