Shezan Baig wrote:
deanfamily11 wrote:
I've got a program that uses functions to various tasks easily. How can I
initalize input and output files outside of the main program?
Not sure what you mean. Do you mean this?:
#include <iostream>
#include <fstream>
std::ifstream inputFile("input.txt");
std::ofstream outputFile("output.txt");
int main()
{
std::cout << "Files have been initialized outside main." <<
std::endl;
return 0;
}
Or maybe this
int main()
{
function1();
function2();
return 0;
}
void function1()
{
std::ifstream inputFile("input1.txt");
std::ofstream outputFile("output1.txt");
...
}
void function2()
{
std::ifstream inputFile("input2.txt");
std::ofstream outputFile("output2.txt");
...
}
Either way its a good idea when asking 'how do I ...' questions to post
the code you have already written. It's often easier to understand what
you want to do then. If you haven't already written some code, then it's
probably good for you to attempt to do so before asking the group.
john