How do I simply compare characters in C++?

I have the following code:

#include <iostream>
using namespace std;
int main()
{
    char fg;
    cin>>fg;
    char x[20];
    x[0]='0';
    if(fg=x[0])
    {
        cout<<"It's true!"<<endl;
        return true;

    }
    cout<<"It's false!"<<endl;
    return false;
}

No matter what input I give, true is always returned. Is my syntax off? Any help would be appreciated.

Leave a Comment