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

You could do something like

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

or

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

Hi Chandra,

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

Thanks
Varun

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.