Append a string to a file
Posted on 2004-04-27
Hello I am trying to create a string variable and append that variable on another line of an open file.
Here is what I have so far
strftime(var, 30, "%m%d", tm_data);
journalfile = "C:\\hlmkejrnl\\" + tmpfilename + ".txt";
// open file with a MMDDhhmmss.txt format to save transaction
ofstream outfile (journalfile.c_str(), ios::app);
string ejrnlfile = "Hope this works";
"Hope this works" should append to the file MMDD.txt file, but I get an error
Cannot convert 'string' to 'const char *' in function main()
Type mismatch in parameter 's' (wanted 'const char *', got 'string') in function main()
Maybe there would be a better way to open a file and append a string to it?