I am trying to make a program that writes information out to a text file on exit and reads it back into the program when it is started again. I am using fstream to do this. I'm having an issue with spaces . I can write a string out to the text using ofstream.
However when I read it back into the program on startup it only reads until the space and completely misses the next word. How do I fix this?
string name = "Bob Patterson";
ofstream output( "data.txt", ios::out );
output << name << endl; //writes the name "Bob Patterson to the file data.txt
ifstream input( "data.txt", ios::in );
input >> inputName;
cout << inputName; //this only outputs the first name "Bob" I want it to say "Bob Patterson";