Still need help fixing it

My game still will not stop with the "press any key to continue" sign, if the wrong path is taken. Please show me what the code should look like in order to do that.
Here it is:


#include<iostream>
#include<string>

using namespace std;

int getans1(char ans, int num);
int getans2(char ans, int num);
int getans3(char ans, int num);

int main()
{
char ans;
int weap; // use int so we don't have to convert


cout << "Choose a tool\n 1. Hatchet\n 2. Body Armour \n 3. Grapling Hook\n";

cin >> weap;





if (weap == 1) { // == as leryss pointed out and open your parenthesis

cout << "\nChoose a path to go through\n a. Wooden Door\n b. Hailstorm Meadow\n c. Rocky Cliff \n";

cin >> ans;



if (getans1(ans, 0))

cout << "\nYou knocked down the door and can move on!\n";




else
cout << "You can't go through this path. Game Over\n";


return -1;



cout << "\nChoose a path to go through\n a. Hammer Room\n b. Mild Woods \n c. Floating Islands \n\n";

cin >> ans;
if (getans1(ans, 1))

cout << "\nYou cut down the trees and can move on!\n ";



else

cout << "You can't go through this path! Game over!\n";

return -1;




cout << "\nChoose a path to go through\n a. Crystal Mountain \n b. Spiked Temple \n c. Secret Locked Chamber \n\n";

cin >> ans;
if (getans1(ans, 2))

cout << "\nYou broke through the locked chamber and found the treasure!\n You win! \n ";



else

cout << "You can't go through this path! Game over!\n";
return -1;

system("pause");



} // closing parenthesis
if (weap == 2) { // open parenthesis

cout << "\nChoose a path to go through\n a. Wooden Door\n b. Hailstorm Meadow\n c. Rocky Cliff \n";
cin >> ans;
if (getans2(ans, 0))

cout << "\n You went through the Hailstorm Meadow unharmed and can move on!\n";

else

cout << "You can't go through this path! Game over!\n";
return -1;


cout << "\nChoose a path to go through\n a. Hammer Room\n b. Mild Woods \n c. Floating Islands \n\n";

cin >> ans;
if (getans2(ans, 1))

cout << "\n You survived the room of hammers and can move on!\n ";



else

cout << "You can't go through this path! Game over!\n";

return -1;



cout << "\nChoose a path to go through\n a. Crystal Mountain \n b. Spiked Temple \n c. Secret Locked Chamber \n\n";

cin >> ans;
if (getans2(ans, 2))

cout << "\n You made it into the Spiked Temple and found the treasure!\n You win! \n ";



else

cout << "You can't go through this path! Game over!\n";

return -1;

system("pause");


} // closing parenthesis
if (weap == 3) {

cout << "\nChoose a path to go through\n a. Wooden Door\n b. Hailstorm Meadow\n c. Rocky Cliff \n";
cin >> ans;
if (getans3(ans, 0))

cout << "\n You went over the Rocky Cliff and can move on!\n";

else

cout << "You can't go through this path! Game over!\n";

return -1;


cout << "\nChoose a path to go through\n a. Hammer Room\n b. Mild Woods \n c. Floating Islands \n\n";

cin >> ans;
if (getans3(ans, 1))

cout << "\n You traveled over the floating islands and can move on!\n ";



else

cout << "You can't go through this path! Game over!\n";

return -1;



cout << "\nChoose a path to go through\n a. Crystal Mountain \n b. Spiked Temple \n c. Secret Locked Chamber \n\n";

cin >> ans;
if (getans3(ans, 2))

cout << "\n You made it over the Crystal Mountain and found the treasure!\n You win! \n ";



else

cout << "You can't go through this path! Game over!\n";

return -1;



system("pause");

}

}


int getans1(char ans, int num)
{
char answer[3] = { 'a', 'b', 'c' };

if (ans == answer[num])
return 1;
else {

return -1;
}

}

int getans2(char ans, int num)
{
char answer[3] = { 'b', 'a', 'b' };

if (ans == answer[num])
return 1;
else {

return -1;
}

}

int getans3(char ans, int num)
{
char answer[3] = { 'c', 'c', 'a' };

if (ans == answer[num])
return 1;
else {

return -1;
}

std::cin.get();
}
A snippet of your coe with proper formatting:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
    if (weap == 1) { // == as leryss pointed out and open your parenthesis
        cout << "\nChoose a path to go through\n"
                " a. Wooden Door\n"
                " b. Hailstorm Meadow\n"
                " c. Rocky Cliff \n";
        cin >> ans;
        
        if (getans1(ans, 0))
            cout << "\nYou knocked down the door and can move on!\n";
        else
            cout << "You can't go through this path. Game Over\n";
            
        return -1; //<<<
        cout << "\nChoose a "//... 
Notice that return -1; is not a part of any conditional branch, which means that program will stop execution at this point and all following code will never be executed.
Topic archived. No new replies allowed.