Hello TheCodingSnake,
A quick look at your full program I noticed this.
1 2 3 4 5 6 7
|
int main()
{
int adventureStatus = 1;
while (adventureStatus == 1)
{
int adventureStatus = 0;
|
Line 3 defines "adventureStatus" with the scope of "main".
Line 7 defines "adventureStatus" with the scope of the while loop. Defining the same variable name is allowed because they are in different scopes.
You should go back to your book and read up on scope or try these links
http://www.cplusplus.com/doc/tutorial/namespaces/
https://www.learncpp.com/cpp-tutorial/scope-duration-and-linkage-summary/
Line 7 defines "adventureStatus" with the scope of the while loop which works fine for the while loop until the end when you reach
std::cin >> adventureStatus; // Even if I enter 5 here the while loop in row 12 repeats
. I believe that you want to change "adventureStatus" defined on line 3, but you are changing the variable defined on line 7. So your while condition is always seeing "adventureStatus" as having a value of (1) because it was never changed.
One other thing I changes is the {}s. When they line up in the same column it makes it easier to see what belongs to what.
Just to let you know it is referred to as the "Allman" style
https://en.wikipedia.org/wiki/Indentation_style#Brace_placement_in_compound_statements There are several different styles to choose from. The choice is yours, but IMHO the "Allman" style seems to be the easiest to read and follow. Which ever style you choose to use
BE consistent in its use. Mixing styles makes the code harder to read.
Andy