ifstream test2("Save.txt");
string str2;
while (test2 >> str2) // while extracting next word successfully
{
cout << str2 << "\n";
}
Also, note the .close()'s in your code are not necessary, because they are called automatically when the stream goes out of scope.
The caveat is that you seem to be implying you expect Save.txt to have more than one number in it. It won't, because you are overwriting the file each time you do lines 9-11.
fstream loadFile("Save.txt", ios::in | ios::out | ios::app);
int a = 0;
int l, e, g, c;
string p, s;
int z = 0;
for (int i = 0; i < 4; i++)
{
while (getline(loadFile,p))
{
getline(loadFile, s);
z++;
if (z == 3)
{
a = stoi(s);
}
if (i + 1 == a&& z==3)
{
saveOrder[i] = p;
loadOrder[i] = p;
z = 0;
}
}
}
for (int b = 0; b < 4; b++)
{
if (b == 0)
{
cout << "0.Back" << endl;
}
cout << b + 1 << "." << loadOrder[b] << endl;
}