Is there anything wrong with this?

Started by
2 comments, last by iMalc 13 years, 6 months ago
#include <iostream>
using namespace std;

int main()
{
char choice;


cout << "Help on: \n";
cout << " 1. if\n";
cout << " 2. switch\n";
cout << "Choose one: ";
cin << choice;
cout << "\n";

switch(choice)
{
case '1':
cout << "The if:\n\n";
cout << "if(condition) statement;\n";
cout << "else statement; \n";
break;
case '2':
cout << "The switch:\n\n";
cout << "switch(expression) {\n";
cout << " case constant: \n";
cout << " statement sequence\n";
cout << " break;\n";
cout << " // ... \n";
cout << "}\n";
break;
default:
cout << "Selection not found.\n";
}

return 0;
}

It's just that I am getting so many errors that I can't even recognize what's wrong.
Advertisement
this: cin << choice;
should be: cin >> choice;
"Spending your life waiting for the messiah to come save the world is like waiting around for the straight piece to come in Tetris...even if it comes, by that time you've accumulated a mountain of shit so high that you're fucked no matter what you do. "
Oh that's right. Thanks, man.
Always solve the errors in order, starting with the first one the compiler gave.
It might give you 100 errors for just one character missing somewhere.
And never forget to post your errors, or at least the first 10 lines of them.
"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms

This topic is closed to new replies.

Advertisement