I'll start with your last question first. To be able to put in i/I at anytime and get the inventory to come up would be easiest to implement by writing your own code to input from the keyboard. Since your are a beginner I would just stick to having menus for now. Besides in most games when you are at the store or some other menu, you don't have access to the inventory anyways. The point here is to have i/I be put in at anytime would require you to program that.
You can start a loop and end it. That would be the c++ keyword break found on this page of the documentation:
http://cplusplus.com/doc/tutorial/control/
As far as ending a loop in one function then going to a loop in another perhaps that would just be a creative use of break. I'll let you figure out break on your own. (In my opinion it is a fun function, just be sure not to miss code you want to always be executed in a loop because of a misplaced break.)
does a function update a global variable without returning anything?
The answer is yes, but only if you actually have code that changes it inside that function. A function only returns something if the function data type is something other than void. Any program function can change a global variable. (This is why most programmers consider it bad practice to use global variables.)
I noticed how you said you weren't thinking ahead. I would suggest to get familiar with how all the loops, if-else statements, functions, etc. all work in this project. Perhaps in the next project you could make an outline of what kind of functions you will need to accomplish certain tasks. Because later on in your programming you will start using classes, and it is recommended to think ahead by that point.
It is usual practice to spread code around to different functions. I once had a teacher say a single function should print out onto one page horizontally. The reason being when a function gets super long it is just plain hard to read. (That is when all those nested loops start to get confusing.)
By the way when you read about break on that page I linked to, also look at the switch statement down at the bottom. You might end up liking switch so much you will use switch code for your menu.
Edit: Also a cool thing about if-else statements, for statements, and a few others is that they can drop the brackets if there is only one statement to execute. EX:
1 2
|
for(int count=1; count<11; count++)
cout << count++;
|