Hello, I made a text application (command line tool) on xcode in C++ that lets you create a text adventure. In the int main you can "program" the text adventure. I made a void called game which is where the game starts once the user decides to test out his "text adventure". The problem is that when I run it void game does not understand the strings because they are in the int main. How would I explain to the void game what the strings are (for example: The games name, the authors name etc). Thank you.
This is a small preview:
String gamename;
getline(cin,gamename);
//More code...
void game (){
cout << "Welcome to" << gamename; - Use of undeclared identifier
}
when you change function you can't access local variables of another function.
So pass the values as argument to function game().Or use class or global variables