Stripping blank spaces and newlines from strings in C
- by Nazgulled
Hi,
I have some input like this:
" aaaaa bbb \n cccccc\n ddddd \neeee "
And I need to sanitize it like this:
"aaaaa bbb cccccc ddddd neeee"
Basically:
Trim all blank spaces at the beginning and end of the string
Strip all new lines
Strip all spaces when there is more than one, but always leave ONE space between words
Is there any easy way to do this or I'll have to process the string, char by char and copy the appropriate chars to a different variable?