lundi 10 octobre 2016

If (cin.fail) not working

I have this homework, but there is one problem. It does not go through my first if and I really dont know why. Can someone please explain what is the problem here?

int main()
{   char a;
    double p, d;
    cout << "Zadejte rovinny obrazec, jehoz obsah a obvod chcete spocitat: a - ctverec, b - obdelnik, c - kruh" << endl;
    cin >> a;
    if(cin.fail())
    {
        cout << "Nespravny vstup." << endl;
    }
    else

    return 0;
}

Aucun commentaire:

Enregistrer un commentaire