1
Min Profile Cycles  [215914]
Max Profile Cycles  [934625]
Max Profile         [23]
Max Profile Count   [4]

How to print all these console output into some .txt file in c so that whenever i will call that function it will print in txt file instead of printing in console.

sam
  • 85
  • 2
  • 7
  • do not use `stdout` but f.e. `stderr` and redirect the error-chanel to the textfile – Peter Miehle Jun 18 '15 at 09:35
  • 1
    http://stackoverflow.com/questions/11573974/write-to-txt-file – GorvGoyl Jun 18 '15 at 09:38
  • possible duplicate of [Effective way to write text file c++](http://stackoverflow.com/questions/20165219/effective-way-to-write-text-file-c) –  Jun 18 '15 at 09:41

2 Answers2

3

as your tag is C, you can fopen() in append-mode a file and instead of using printf() you use fprintf() (and fwrite() and similar) with this filehandle.

Peter Miehle
  • 5,984
  • 2
  • 38
  • 55
  • Basically in my case prinf is disabled due to memory constraint in that case how to print the valyes. – sam Jun 18 '15 at 14:38
1

One easy way would be to write something like this in your shell :

$./a.out > hello.txt
Sourav Kanta
  • 2,727
  • 1
  • 18
  • 29