That message from the compiler is Cplusplusinese for 'std::endl is an output only entity'. You can only send it to output streams. You're trying to read it from std::cin, which just isn't going to happen. Also, LoGiCaL__ already pointed out a flaw in the bracketing. You included a closing bracket after the if
statement, without first opening it. Then when you got to your else
clause, you did the complete opposite. This is going to cause the compiler to get all pissy.
Here, this should work:
- Code: Select all
using namespace std;
int main ()
cout << "what is x?" << endl;
// can't read std::endl from std::cin
cin >> x;
// missing opening bracket fixed
if (x == 2)
cout << "you entered a two!" << endl;
cout << "you entered a one!" << endl;
Hopefully that helps. Also, this ~>website
<~ might help too. Be sure to check out the sourcecode section. There are tutorials available for download.