I see, the behavior would be the same, with the last two characters, both '\n', being located at i-2 and i-1, you are checking i-1 ('\n') and i (garbage), that is why the loop isn't stopping
edit: actually, the problem looks worse than that,always checks garbage (the data is entered in words[0] and you check to see if words[1] contains '\n')Code:do { scanf("%c", &words[i]); i++; } while(words[i] != '\n');