Let's parse.

This commit is contained in:
Simon Forman 2023-02-01 16:02:19 -08:00
parent e32d1d22e6
commit b8b37af1a4
2 changed files with 24 additions and 0 deletions

View File

@ -1 +1,2 @@
joy
parser

View File

@ -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, " []");
}
}