Code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void save(int i, double d, const string &str)
{
ofstream fout("save.txt"); // no error checking
fout << i << endl
<< d << endl
<< str << endl;
fout.close();
}//save
void load(int &i, double &d, string &str)
{
ifstream fin("save.txt"); // no error checking
fin >> i >> d;
fin.ignore(1); // skip newline
getline(fin ,str);
fin.close();
}//load
int main()
{
int i = 42;
double d = 3.1415926535897932384626433832795;
string str = "life is like a piece a pie";
save(i, d, str);
i = 0;
d = 0;
str = "";
load(i, d, str);
cout << i << endl << d << endl << str << endl;
return 0;
}//main
gg