LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to call other executables from cpp code (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-call-other-executables-from-cpp-code-782947/)

er.saurabh 01-18-2010 06:46 AM

How to call other executables from cpp code
 
Dear experts,

I want to launch other executable from my cpp code.

I am aware that system() call may do this ,

But, problem is that , I want my cpp code to capture the standard
out ,what "called" program is writing to stdout.


Have anybody have any idea...

Thanks..

neonsignal 01-18-2010 07:21 AM

The popen function will do this for you. Use the "r" type to capture the standard output.

Note that if you want to control both the standard input and the standard output of the other executable, you will need to make use of fork and exec, and redirect the io streams.

er.saurabh 01-18-2010 08:23 AM

thanks got...


All times are GMT -5. The time now is 11:36 AM.