4 ms·
Also useful for storing parse results: "<a href='blah'>" gets modified during parsing to become: "<a\0href\0'blah\0>" Your parse tree result result
by cma 16y ago
Also useful for storing parse results:
"<a href='blah'>"
gets modified during parsing to become:
"<a\0href\0'blah\0>"
Your parse tree result result can then just contain pointers to "a\0", "href\0", and "blah\0" rather than doing any copying.
- deutronium 16y agoThis is how strtok returns tokens too. Incidentally I only found this after trying: char tmp[] = "cat,mat,sat"; char *t; t = strtok(tmp,","); while(t != NULL){ printf("%s\n",t); t = strtok(NULL,","); } And getting a segfault, as 'tmp' is not writeable memory.