What I am trying to do is redirect all my cout to a file, rather than a console. I am using a gcc complier to run my program. It works well when I do
./a.out > output.txt.
But i was wondering is there a way i can do the same thing but inside my code, that will call all my cout to a file?