Author Topic: save console output on file  (Read 13763 times)

Offline polisbul

  • Multiple posting newcomer
  • *
  • Posts: 17
save console output on file
« on: November 26, 2012, 05:59:11 pm »
does anyone know how i can save my console application output on a text file? is there any option inside code::blocks?
I'd like an option like
Code
g++ main.cpp > output.txt
on linux.
thank you

Offline cbuser2

  • Multiple posting newcomer
  • *
  • Posts: 33
Re: save console output on file
« Reply #1 on: November 27, 2012, 10:58:46 am »
After your program is compiled, find the executable, then pipe it into a file.

So if your executable is called "program", then ./program > output.text

Offline polisbul

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: save console output on file
« Reply #2 on: November 27, 2012, 11:42:43 am »
ok, i can do it by terminal, is there an option to include the command " > aaa.txt " inside code::blocks?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9702
Re: save console output on file
« Reply #3 on: November 27, 2012, 12:08:31 pm »
ok, i can do it by terminal, is there an option to include the command " > aaa.txt " inside code::blocks?
You can easily achieve his: Setup as tool that (using macros) will always start your projects/targets executable. Then configure to pipe the standard out to an internal console. From here, you can easily copy/paste the std::cout as you like.

Note that using similar macros and setting up the tool to run visible, detached you can even do the pipe operation, if you like.

Also note that this command will work for any projects/targets you have, if you use the proper macros.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ