Removing a specific element from a string in C++

  c++, data-structures

I was trying to remove X from a given string,the code compiles and runs and there is no output shown.I guess the problem is with that where i have to use the ‘cout’ operator.

Here is my Code:

#include<iostream>
#include<bits/stdc++.h>
#include<string.h>

using namespace std;

void removeX(char str[])
{
    if(str[0]='{$content}')
    {
        cout<<str;
    }

    if(str[0]!='x'||str[0]!='X')
    {
         removeX(str+1);
    }
    else
    {
        for(int i=0;i!='{$content}';i++)
        {
            str[i]=str[i+1];
        }
        removeX(str+1);
    }
}

int main()
{
    char a[]="MALCOLM X";
    removeX(a);
    return 0;
}

Source: Windows Questions C++

LEAVE A COMMENT