C code to summarize a string of tokens