Problem creating load

I am making a new game and i am a beginner in C++
I was trying to make a load function but the problem is
that i need to define the fstream in the load() too
I have already written it in main() but it says it is not
declared in load(). Is there a way i can make it load using
the other function?
I want to read from a file after writting in the file.
Or can anyone give me a save/load game sample just to have an
idea.
How can i use a variable inside a function in another function?
How am i supposed to load the game???
It is not a variable. This is my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
int main()
{
cout << "Enter your name: \n";
    string a;
    cin >> a;

    cout << "Choose points for life, attack and speed\n";
    cout << "Max points to use is 20\n";
    int b, c, d;
    cin >> b >> c >> d;

    cout << "Welcome " << a << "! \n";
    cout << "You have " << b << " life, " << c << " attack and " << d << " speed\n";

    ofstream lavaGame;
    lavaGame.open("Save Game.dsp");

    lavaGame << a << " " << b << " " << c << " " << d;
    lavaGame.close();
}
Topic archived. No new replies allowed.