November 19th, 2008, 10:04 PM
String if statements?
I am very new at programming with C++. I am taking a class on it and I want to wow my teacher for an A. I am writing a simple textual input/output program and I want to know how I would do this part of it.
int main ()
cout << "type Yes or No" << "\n";
cin >> a;
if (a == "Yes")
cout << "textline one";
cout << "textline two";
I thought that this made sense, but for some reason it does not work. My program simply prints "textline one" whether the input was Yes or No. Can anyone explain this for me??
Thank you in advance for any help you provide.
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!