Hi, need some help here.
i have an idea of -
i am trying to make it into functions so that i can have multiple threads writing to the file using the same stream. i understand that declaring the ofstream variable as global will be one solution. however, due to requirements, that cannot be done.Code:int main() { ofstream ofs; } void openFile(ofstream var_ofs) { var_ofs.open(arg); } void writeFile(ofstream var_ofs) { var_ofs.write(arg); }
how can this be done without using global variables? i have tried passing the ofstream as pointer but that wouldn't work too.