Advertisement

[java] 2 questions

Started by June 26, 2000 09:02 PM
10 comments, last by Smoo 24 years, 6 months ago
Sure you can pass chars to a switch. I just made a sameple project confirming this. Heres the code:

#include

void main()
{
char letter = NULL;

cout << "Enter a letter." << endl;
cin >> letter;

switch(letter)
{
case ''a'': cout << "Hello" << endl; break;
case ''b'': cout << "Bye Bye" << endl; break;

default: cout << "I dont understand" << endl; break;
}
}

I think you can also pass strings and in the case part you would do this case "string": but i dont remember if i have ever done that or not.

-Snyper



=============================Where's the 'any' key?=============================
Not too shabby Snyper, but he''s doing his proggie in java

War doesn't determine who is right, war determines who is left.

This topic is closed to new replies.

Advertisement