Link to home
Start Free TrialLog in
Avatar of Karls
Karls

asked on

writing to files from different functions

I am opening a file in main func using

ofstream atminit ("atminit.txt");
if (! atminit.is_open())
{
cout << "error opening atminit.txt, press any key to  exit.....";
getch();
exit (1);
}
else
{
cout << "opened atminit file ok" << endl;
}

I want to write some information to the file from a different function.  Is it possible to open the file globally?  can I pass a pointer of the file to the function and write to the pointer?  If so then how do I open it as a pointer and how do I write to it.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of mblat
mblat

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial