If statement with a char

how can i make my program ask for a char("Q") to quit/initialize
the if statement?
i get an c3867 error when i run it. but i can't see what i do wrong

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
 /*
			Body of program
*/

#include <iostream>
#include <string>
#include "headerRpg.h"


using namespace std;

char a;

roomOne::roomOne()
{

	cout << "apples are cool" << endl;

	cin >> a;
	cin.ignore();

	if (a == 'Q')
	{
		cout << "quitting...." << endl;
		cin.ignore;
	}	
}

Thanks for the help
On line 25: Add the parentheses: cin.ignore();
You can use the exit() function defined in stdlib.h .

1
2
3
4
5
6
7
8
9
10
11
12
13
#include<iostream>
//other includes.....
#include<stdlib>

using namespace std;

//passing to the main point

if(a=='Q'||a=='q')
{
cout<<"Quitting...."<<endl;
exit(0);
}


You have to specify the '0' in the exit() function by the way.
Topic archived. No new replies allowed.