hi i want open() accept a pointer or a reference to an ofstream object. That way, it can modify the ofstream object and pass the modified object back to the caller.
but having trouble with my coding
my compiler crashes..and i can't find the error becoz of that
can anyone check whats wrong
basically i want to open a new fstream file with any string name and pass it back to the main so it can be used..
Code:
#include<string>
#include<iostream>
#include<fstream>
void &open(ofstream&);
string filename;

void &open(ofstream &a)
{

cout<<"name of file to save"<<endl;
getline(cin,filename);

a.open(filename.c_str(),ios::in| ios::out);
a<<"writing this to a file\n";
a.close();

}

int main()
{
ofstream b;
cout<<"testing how open files from another function"<<endl;
open(b);
return 0;
}