I am trying to print all of my output from the console onto a txt file. I know how to do it simply like this:
int main()
{
ofstream outfile;
outfile.open("Text.txt");
outfile << "Hello World!\n";
outfile.close();
}
But I am trying to do it in this program, since of most of my functions use 'cout', using 'myfile' for each print is very robust. I am trying to it this way, but not sure if it is better to do it as a function:
int main()
{
string st;
ofstream myfile;
myfile.open("Game.txt");
myfile << st;
Player P1("player 1 ", true);
Player P2("Computer", false);
Board myboard(1);
int cardno;
int pos;
cout << "\n\n\n Please select a position on Board: ";
getch();
myfile.close();
cout << st;
return 1;