I don't like the way this was explained, maybe this is better.
Basically you have two strings, one is the longer string that the user entered called string A, and the string with excess white space removed. Notice that you are either in a white space section or a character section when copying A to B. Find out what section you start out in, and control your logic, by testing each character to see if it is a white space character or not. While you are in the white space section, keep moving forward in A. While you are in the character section, you will copy stuff from A to B. If you need to switch from the character section to the white space section, put a space at the end of B. When you reach the end of A, end B.
So, keep track of the current place in A and the current place in B with separate variables. In all likelihood they will be different.