Code won't work?

The problem I have is how to do a switch where I have to call the certain choices.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

int main(void)
{
do 
{
cout << "Hello there ." << endl;
cout << "Select from the menu." << endl; 
cout << "A gets lyrics." << endl; 
cout << "B gets artist." << endl; 
cout << "Q quits the program." << endl;
cout << "Your choice: --> " << endl;
cin >> user_choice; 

switch (user_choice)
{
case 'A': lyrics 
break; 
case 'B': artists
break; 
} 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
using namespace std;

int main(void)
{

do 
{
	cout << "Hello there ." << endl;
	cout << "Select from the menu." << endl; 
	cout << "A gets lyrics." << endl; 
	cout << "B gets artist." << endl; 
	cout << "Q quits the program." << endl;
	cout << "Your choice: --> " << endl;

	char user_choice;
	cin >> user_choice; 

	switch (user_choice)
	{
		case 'A': cout << "lyrics " << endl;
		break; 
		case 'B': cout << "artists" << endl;
		break; 
	}
}
while(0);

return 0;

} 
I don't understand what do you mean. The syntax of switch is OK. Problem is that you don't have defined lyrics and artists but I think that this is part of code only.
if lyrics and artists are functions that take no parameters, you need to have () after them, along with a ;
Topic archived. No new replies allowed.