Jeff King <peff@xxxxxxxx> writes: > Something like: > > for (line = buf; *line; line = next) { > next = strchrnul(line, '\n'); > > ... do stuff ... > /* find a space within the line */ > space = memchr(line, ' ', next - line); > } I am not sure about the memchr() thing, but "prepare next that is constant thru the iteration, and update line to it at the end of each iteration" is a robust pattern to follow. I like it.