ECHO PROGRAM WITH SWITCH

hey please tell me why this program is not stop in specific case please tell me

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
32
33
34
#include<iostream>
using namespace std;
int main()
{
	int choice;
cout<<"Press 1 For Running Echo Program:"<<endl;
cout<<"Press 2 For Simple Written Program:"<<endl;
cin>>choice;
switch (choice)
{
case1:
{
	cout<<"********WELCOME TO ECHO PROGRAM**********"<<endl;
	cout<<"*****************************************"<<endl;
	std::cout << std::cin.rdbuf();
	break;
}
case2:
{
	int a;
	cout<<"Write Any Thing:"<<endl;
	cin>>a;
	cout<<a;
	break;
}
default:
	{
	cout<<"Sorry Go Home";
	}
	break;
}
system("PAUSE");
return 0;
}
I dont think you intended to type "case1:" and "case2:" (no space between case and 1)
This way C++ treats them as labels and not as cases for switch. Add space between the word "case" and the numbers
Topic archived. No new replies allowed.