I am trying to remove spaces from a string in c, not from the end, nor the beginning, just multiple spaces in a string
for example
hello everyone this is a test
has 2 spaces between hello and everyone, and five spaces from this to is. Ultimatley i would want to remove 1 space from the 2 and 4 from the 5, so every gap has 1 space exactly. Make sence?
This is what i was going to do,
create a pointer, point it to the string at element 1 char[0].
do a for loop through the length of the string
then my logic is, if my pointer at [i] is a space and my pointer at element [i+1] space then to do something
i am not quite sure what would be a good solution from here, bearing in mind i wont be using any pre built functions. Does anyone have any ideas.
Please dont provide any solutions as i am doing this for homework, i just cant see what to do when i no there is a space after another.
thanks
wow - somne really good answers for me to get cracking with - thanks for the help guys
i am sorry that i have not picked a correct answer - which one i pick is a little hard to choose as they all make sence. maybe a mod could do it dependant on what they think.