vendredi 21 octobre 2016

C++ If-else statement using strings and comparing strings

when I enter (Im qwerty) as (y), the program shows "Your account has been deactivated" instead of "Your password is incorrect". I've searched for same problems but const. char and using strcmp is too complicated for me and my instructor does not use that kinds of codes.I'm very eager to know what must I do to make my program right. (Tnx in advance)

#include <iostream>

using namespace std;

int main () {
string y;
cout << "Enter Icode: ";
cin >> y;


if (y == "Im robbee")
    cout << "Your password is incorrect.";

else
    cout << "Your account has been deactivated.";



cin.get();
return 0;

}

Aucun commentaire:

Enregistrer un commentaire