I wrote a program to remove spaces from string in c++. But when i compile this program i got two errors. They are `error: initializer fails to determine size of ‘str1’` and `error: array must be initialized with a brace-enclosed initializer`.

Can any one show me the error of my code. I am new for C++. I mentioned my code below

```
#include <stack>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

char *delSpaces(char *str)
{
    int i = 0, j = 0;
    while (str[i])
   {
    if (str[i] != ' ')
       str[j++] = str[i];
    i++;
   }
    str[j] = '\0';
    return str;
}

int main(){
    string s;
    cin >> s;
    char str1[]=s;  
    cout << delSpaces(str1);
}

```