I know the title is a little confusing, but I don't know how to explain it.
void save (POINT pt)
{
ofstream save;
save.open("coords.txt", ios::trunc);
if (save.is_open())
{
save << pt.x << endl;
save << pt.y;
save.close();
system("CLS");
cout << "Save successful\n\n\n\n";
system("PAUSE");
}
else
{
system("CLS");
cout << "Error: Could not save\n\n\n\n";
system("PAUSE");
}
}
int load ( )
{
ifstream load;
load.open("coords.txt", ifstream::in);
if (load.is_open())
{
}
}
I want to read the POINT
from the save function inside of the load function. I tried
if (load.is_open())
{
load >> pt.x;
load >> pt.y;
}
but pt.x
and pt.y
are undefined. I'm not very good at this, but I 'm trying to understand it.
Thanks in advance!