Thursday, July 30, 2009

Remove the spaces in a string through C++?

I'm writing a program and i need to be able to input:





x =4+ 5 or x = 4 + 5





and get:


x=4+5 (no spaces)





Anyone got some tips for me?

Remove the spaces in a string through C++?
In pseudocode:


accept input from user and assign to a variable A


get length of A and put in B


for loop 1 to B


get character B in mid string


compare to ascii code for space


if not equal space append to variable C


next loop


output C


end


No comments:

Post a Comment