Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 01-18-2010, 07:46 AM   #1
LQ Newbie
Registered: Dec 2009
Posts: 13

Rep: Reputation: 0
Lightbulb 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...


Last edited by er.saurabh; 01-18-2010 at 08:15 AM.
Old 01-18-2010, 08:21 AM   #2
Senior Member
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Bookworm (Fluxbox WM)
Posts: 1,391
Blog Entries: 53

Rep: Reputation: 360Reputation: 360Reputation: 360Reputation: 360
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.
1 members found this post helpful.
Old 01-18-2010, 09:23 AM   #3
LQ Newbie
Registered: Dec 2009
Posts: 13

Original Poster
Rep: Reputation: 0
thanks got...


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
call the C executable inside the C is noname Programming 9 01-09-2010 10:28 AM
[SOLVED] How to call cpp library function in c code? eryn Programming 19 12-07-2009 02:41 AM
How to call system call from usb driver's code Mr.J Linux - Kernel 4 09-29-2008 04:47 AM
problem of function call address in executable file valpa Programming 12 09-05-2008 09:36 AM
AIX System Call in Cpp varunharidas AIX 2 08-03-2006 08:42 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:06 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration