Writing ALL program output to a txt file in C++

前端 未结 5 1406
生来不讨喜
生来不讨喜 2021-01-05 02:45

I need to write all my program output to a text file. I believe it\'s done this way,

sOutFile << stdout;

where sOutFile is the ofstr

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-05 03:03

    sOutFile << stdout;
    

    in C "stdout" is defined as a FILE* variable. It's just a pointer. Outputing it to a file just writes the value of the pointer, in your case: 0x77c5fca0 to the file.

    If you want to direct your output to a file either write it the a file in the first place or redirect the output of your program to a file using the command line.

提交回复
热议问题