• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 345
  • Last Modified:

PrintF to a file

I am looking to spit all my printf's out to a file so I can track exactly what is going on within my Code so I can more accurately debug any issues.

How do I set this up?
0
directxBOB
Asked:
directxBOB
1 Solution
 
Infinity08Commented:
Do you want this without changing your code, if so, then execute your application like this :

        myapp > log.txt

That way, the standard output (stdout) is redirected to the log.txt file.

If you want to change your code, then you can use fprintf :

        http://www.cplusplus.com/reference/clibrary/cstdio/fprintf.html

instead of printf. And of course fopen and fclose to open and close the log file :

        http://www.cplusplus.com/reference/clibrary/cstdio/fopen.html
        http://www.cplusplus.com/reference/clibrary/cstdio/fclose.html

(take a look at the example code on those pages)
0

Featured Post

Firewall Management 201 with Professor Wool

In this whiteboard video, Professor Wool highlights the challenges, benefits and trade-offs of utilizing zero-touch automation for security policy change management. Watch and Learn!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now