This works OK. Declare x as a char array of 10. Since the word lottery is a string and not a character it must be enclosed in double quotes (").
A better solution would be to define x as a string type.
#include <iostream.h>
void main()
{
char x[10];
cout << "Pick a word: ";
cin >> x;
if (x == "lottery")
{
cout << "You win the C++ lottery!" << endl;
cout << "Thank you for playing the C++ lottery" << endl;
}
else
{
cout << "Thank you for playing the C++ lottery" << endl;
}
}
Keep reading the book :-)
Alan
|