The problem is looking for the start of each subsequent word: current = next + 1 . You want to look for the first ...
stackoverflow.com