string person;
string message;
string date = "11/23/12";
string time = "11:45 PM";
cout << "Who would you like to send a message to?";
getline(cin, person);
cout << "Please type the message that you would like to send: " << endl;
cout << "Please also note that pressing the enter key WILL send the message, so don't" << endl
<< "press enter unless you want to send the message." << endl << endl;
getline(cin, message);
string title = person + " " + date + " " + time + ".txt";
cout << title;
ofstream outfile;
outfile.open(title.c_str());
outfile << title << endl << endl << message;
//need to put who the message is from
outfile.close();
Why wont this work? I have done everything as usual, only changed the way that the title for the file was defined. The code itself works as I have changed title to just 'person' or just 'date' and it will write to that file. However, as soon as I concatenate two strings and try to use that, it doesn't write anything.
EDIT: changed "string title = person + " | " + date + " | " + time + ".txt";" to "string title = person + " " + date + " " + time + ".txt";"
I have realized that, but I had added those at a later time to separate the variables and distinguish them, it did not work before that point.
Thanks for noticing. The file system is NTFS.
I have just tested it again and it still does not work. :/