Hello All,
I would like the user to be able to choose the file_name (assuming it already exists) and be able to append information to it. However, this condensed version, below, of what I'm trying to do gives me a compilation error. I feel like it has something to do with the data type I chose for file_name. If I switch to char*, then the program compiles fine, but results in a bus error after executing it. I am a little new to this, any explanation would be greatly appreciated!
#include <iostream>
#include <string>
#include <fstream>
#include <cstdlib>
using namespace std;
int main()
{
string file_name;
ofstream infile;
cout << "Enter name of file: ";
cin >> file_name;
infile.open( file_name, ios::app );
cout << infile.fail();
return 0;
}