I've been working on saving to files and this was the result. The only problem is that anything after a space is ignored, (if you typed "john smith") it would print ("the last person to use this file was: john") I am using codeblocks with the GNU GCC compiler. Here is the code:
#include <iostream>
#include <cstdlib>
#include <fstream>
using namespace std;
int main()
{
string name;
ofstream saveData;
ifstream Data;
Data.open("Info.data", ios::binary);
Data >> name;
Data.close();
cout << "The last person to use the file was " << name << endl;
cout << "What is your name?" << endl;
cin >> name;
saveData.open("Info.data", ios::binary);
saveData << name;
cout << name << endl;
system("PAUSE");
saveData.close();
return 0;
}
thanks