I'm reading Wrox's "Beggining programming" and in chapter seven the author brings some code that works perfectly, both in the compiler and the .exe:
Code:
#include <iostream.h>
void main()
{
int x;
cout << "Pick an integer: ";
cin >> x;
if (x == 7)
{
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;
}
}
My question is, how it is possible to write the same mini-program but picking up a letter instead of a number. Let's say, that by picking up the letter "a" or the word "lottery" I win the "C++ lottery". I tried to write this code (see bold type)
Code:
#include <iostream.h>
void main()
{
int x;
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;
}
}
And the compiler found this code mistaken

. Any suggestions on how to code this properly?
Thank you for your time :D. I would appreciate very much an answer to this .