I am trying to learn C++ and am trying to figure out how to use strings and if statements together. Here's the code I'm trying to play around with:
#include <iostream.h>
int main()
{
char * a;
cout << "Do you want to enter?\n"<<endl;
cout << "To enter, type yes. Otherwise, type no. \n"
cin>>a;
if(a = "yes")
{
cout<<"\nYou open the door";
}
else if (a = "no")
{
cout<<"\nYou walk away from the door";
}
}
Every time I type in no, the statement "You open the door" pops up. Anybody know what I'm doing wrong?
Thanks