cpp program to temove space from string

Solutions on MaxInterview for cpp program to temove space from string by the best coders in the world

showing results for - "cpp program to temove space from string"
Antonio
16 Jan 2018
1#include<iostream>
2#include<string.h>
3using namespace std;
4int main ()
5{   char str[80];
6    int i=0, len, j;
7    cout << "Enter a string : ";
8    gets(str);
9    len = strlen(str);
10    for( i = 0; i < len; i++)
11    {
12        if (str[i] == ' ')
13        {
14            for (j = i; j < len; j++)
15                str[j] = str[j+1];
16            len--;
17        }
18    }
19    cout << "Resultant string : " << str;
20    return 0;
21}