Menu key, change from int to char

So wasn't quite sure how to word the problem for the Title but my problem should be quite simple for someone with decent knowledge of C++.

Basically I am creating a text based RPG and I currently use numbers to navigate everything, and this isn't a problem until I need a menu key.

I need to be able to take the userInput and accept a char to open the menu.

Here is a sample for what I mean;

1
2
3
4
5
6
7
8
9
10
11
	while (running){ // Will loop while running = 1
		if(playerLocation == 1) {
			cout << "You are standing in the middle of a forest. A path veers of the East and to the West\n";
			cout << " 1: Go East\n 2: Go West\n";
			cin >> userInput;

			if(userInput == 1) playerLocation = 2; // East
			else if(userInput == 2) playerLocation = 3; // West
			else if(userInput == 0) menuFuncNav(); // Opens the menu.

		}


Where else if(userInput == 0) menuFuncNav();

I need to be able to accept a char such as "x" and still take in the numbers. I tried using it as a string and just putting the numbers in "" but the problem is that I have code that uses the userInput in part of the menu to select the weapon from the array.
Last edited on
Topic archived. No new replies allowed.