I am new to C++ (as is evident by this simple quewstion), but if anybody could take the time to help..
I am trying to get a simple program to write user-specified contents to a file. I have the basics working, but it will cut anything off from the content after a space is entered. Here is the code I have. (I realize this is probably not the best way to go about doing this, but I'm trying to keep it simple, as I am still very new to C++ programming.
Code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
string content;
int main () {
cout << "Enter your content: ";
cin >> content;
ofstream myfile;
myfile.open ("example.txt");
myfile << content; //this does not allow spaces; only the first set of chars before the space will be included
myfile.close();
return 0;
}
When the program is ran, anything after a space in the entered content is cut off, and is not written to the file.
Any help would be appriciated.