954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Saving compiler output in a text file

Hi,

I want to write a program which can compile a different C++ file. And I want to save the output , which I will get after compilation in a different text file. For Example:- I have got two C++ files called file1.cpp and file2.cpp in the same directory. Now, the code which I want to write in file1.cpp should compile file2.cpp and if there is any compile time mistake in file2.cpp then it should a generate a new text file which will store the compiler error message we got by compiling file2.cpp !

How can this be done ? I have never written a program like this before !

Thanks

vsha041
Newbie Poster
14 posts since Jul 2008
Reputation Points: 8
Solved Threads: 2
 

You could do something like

system("cc -c test.cpp | tee out.log")


or

system("cc -c test.cpp >> out.log")
Agni
Practically a Master Poster
655 posts since Dec 2007
Reputation Points: 431
Solved Threads: 116
 

Hi Chandra,

Thanks man, I will try it and see. By the way what does "tee" mean ? Is that a command ?

Thanks
Varun

vsha041
Newbie Poster
14 posts since Jul 2008
Reputation Points: 8
Solved Threads: 2
 

yes 'tee' is a unix command that splits the pipe into stdout and files. Probably i should have specified that these will not work for windows.

Agni
Practically a Master Poster
655 posts since Dec 2007
Reputation Points: 431
Solved Threads: 116
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You