I am trying to write a program but i have ran into a problem i need to save a sentence and output it into a text file and i can not seem to get it to work can someone please tell me what to do and give me a example?
i know this is wrong but these is what i want to do
char date;
out << "Enter date" <<endl;
cin >> date;
ofstream myfile;
myfile.open ("date.txt");
myfile << date
myfile.close();
but it always comes out the first word even when i try doing strings someone help?
Are you having the sentence being entered by the user? So where it says cin >> date;??? If so you only get the first word because cin will only read in up until a space. So you need to use getline.
getline(cin, fname);
There are a few getline's I get them confused but I think this will solve your issue.
Please use code tags when you post it makes it so much more readable.
Let me know if the issue is fixed.