Just wondering how you save a variable to a text file,
like say I had a variable called EnteredInformation, and it held all the information that a user entered into a form, how would I then put that into a text file??
Thanks
-|- Hurgh -|-
Printable View
Just wondering how you save a variable to a text file,
like say I had a variable called EnteredInformation, and it held all the information that a user entered into a form, how would I then put that into a text file??
Thanks
-|- Hurgh -|-
Sorry and one other thing,
How would I then later get the information that I put into that text file and put it back into the variable??
Thanks Heaps
-|- Hurgh -|-
I think that should compile...you get the idea though :)Code:#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void main() {
string sText = "Hello!";
{
ofstream OutFile("myfile.txt");
OutFile << "Text: " << sText << endl;
}
{
ifstream InFile("myfile.txt");
InFile >> sText;
cout << sText << endl;
}
}