I'm trying to write a string I entered into the program to a file. I won't explain it though, it's probably easier if I just post the code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
string input;
cin >> input;
fstream myupdate ("G:\\Documents \\C++\\myfile.t xt", ios:: out | ios::app);
myupdate << update << endl << endl << endl;
myupdate.close( );
return 0;
}
Problem is, if I type in a string, the first space I hit is where it ends. For instance, if I type the words in the program window "Work you piece of crap!!!" it would just write "Work" to the file and that's it. Apparently that's all that gets written to the string 'input' and so that's all that gets written. Anyone know how to get everything I type in the program window including spaces put into the variable?
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
string input;
cin >> input;
fstream myupdate ("G:\\Documents \\C++\\myfile.t xt", ios:: out | ios::app);
myupdate << update << endl << endl << endl;
myupdate.close( );
return 0;
}
Problem is, if I type in a string, the first space I hit is where it ends. For instance, if I type the words in the program window "Work you piece of crap!!!" it would just write "Work" to the file and that's it. Apparently that's all that gets written to the string 'input' and so that's all that gets written. Anyone know how to get everything I type in the program window including spaces put into the variable?
Comment