...

/

Remove White Spaces from a String

Remove White Spaces from a String

Given a null-terminated string, remove all the white spaces.

Statement

Given a null-terminated string, remove all the white spaces (tabs or spaces) present in the string.

Example:

Sample input

All greek to me.    

Expected output

Allgreektome.

Let’s visualize this below:

Try it yourself #

#include <iostream>
#include <string>
using namespace std;
string RemoveWhiteSpaces(char * str) {
//TODO: Write - Your - Code
string s = str;
return s;
}

Solution

This problem can be solved with two pointers. Here is an ...

Access this course and 1400+ top-rated courses and projects.