;; This buffer is for text that is not saved, and for Lisp evaluation. ;; To create a file, visit it with C-x C-f and enter text in its buffer. abc def ghi -- three fields abc;;;def -- four fields, middle two empty ;abc; -- three fields, outer ones empty strtok(3) // whitespace separated fields for (char *field = strtok(input, " \t"); field; field = strtok(NULL, " \t")) { // handle each field } strsep(3) // hard delimiters char *field = input; for (char *ip = input; true; ++ip) { if (*ip == '\0' || *ip == '\n') { // print chars field up to up break; } if (*ip == delim) { // print chars field up to ip field = ip + 1; } } char *field = NULL; char delims[2] = { delim, '\0' }; while ((field = strsep(&input, delims)) != NULL) { // output field }