
Saqib H. answered 03/29/20
PhD in Computer Science with expertise in Python
There are two solutions:
- Use an inbuilt erase() function in c++ to remove white spaces from the string.
- Write a for loop and build the string. Inside the for loop you can check if there is a white space in the string then just increment the iterator otherwise update the string with the character at that particular index.