I'd suggest 2 loops. One that iterates through from the beginning of the string and one from the end. In the first loop, you can use memmove() to keep copying index+1 to index as long as string[index] is a space, tab, or new line. In the second loop you can just keep setting string[index] to '\0' as long as string[index] is a space, tab, or new line.
|