Something is wrong with char y. Not indetified

I think it is missing, I think you call it , a header file for char y? But cant remember what it is called. If my assumption is correct can some one tell me what it is. If not can you tell me what is wrong? Thanks!


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
35
36
37
38
39
40
#include <iostream>
#include <string>
//I think I missing something here. the output is saying " 'y' : undeclared identifier  "
using namespace std;

int main ()
{
	
	int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	string month[] = {"January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
   
	string answ;
	int num;
	do {
		cout << "Enter a number between 1-12  ";
        cin >> num;
		
		if(num > 0 && num <= 12)
		{
			
		--num;
		cout << month[num] << " has " << days[num] << endl;
		cout << "would you like to continue?" << endl;
		cout << "y or n" << endl;
		cin >> answ; 
		}

		else
		{
			cout << "please enter a number between 1-12\n\n" << endl;
			continue;
		}
	} while ( answ == y);

  
	

  system("pause");
  return 0;
}
y is a variale, but you didn't declare it: for example int y;

in your case you simply forgot these ""
so change line 33 to } while ( answ == "y"); and it'll work
thank you
Topic archived. No new replies allowed.