Zeotronic
February 17th, 2008, 05:04 PM
I've been writing code that stores very related (in fact interdependant) information in different files, the only reason I have it do this is because I wanted the code in different segments that could be accessed by other code... but it just occured to me that I could probably have this code share fstream (actually ifstream and ofstream, not interchangibly mind you) in a fashon similar to this:
void slave(fstream file)
{
}
void master(string filename)
{
fstream file(filename);
if (file.good())
{
//Use file, then...
slave(file);//Let slave use file.
}
}
While I personally suspect this would work, I thought I should make sure, and should check if it would also pass along the current position of the pointer which is used to access information from within the file.
void slave(fstream file)
{
}
void master(string filename)
{
fstream file(filename);
if (file.good())
{
//Use file, then...
slave(file);//Let slave use file.
}
}
While I personally suspect this would work, I thought I should make sure, and should check if it would also pass along the current position of the pointer which is used to access information from within the file.