Typing "exit" to exit program

Good evening everyone! I'm new to both C++ and the forums but have searched everywhere and have not found what i have needed.
I need help setting up code so that whenever I(or anyone else) types in "exit" to exit the program. Any help is appreciated.
Note: this is only for debugging purposes NOT for any real program.
What does your code look like for getting user input? It's hard to tell you how to proceed without knowing where you started.
Here it is:
1
2
3
4
5
6
7
8
int main()
{
	...
	cin >> SHOOT;
	cout << " Press Enter to continue...";
	cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );
	...
}
What type of variable is SHOOT?
it's a string variable. -EDIT-I believe I have something that will work for debugging and laziness purposes.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
#include <limits>
#include <string>
using namespace std;



int main()
{
	int exit = 0;
	
	while ( exit < 1 )
	{
		cin >> exit;
	}
	return 1;
}  
unless you can give me a more efficient/better way(which i'm sure you do =) ).
Last edited on
if(SHOOT == "exit")
return 0;
thanks. =)
Topic archived. No new replies allowed.