LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-24-2004, 11:42 PM   #1
gajaykrishnan
Member
 
Registered: Jul 2004
Posts: 65

Rep: Reputation: 15
how to a start another application from my c++ program?


how do i start another application from my c++ program ?????
 
Old 07-24-2004, 11:57 PM   #2
gizmo_thunder
Member
 
Registered: Apr 2004
Posts: 101

Rep: Reputation: 15
Is it on Windows or linux..???
in linux there is a system call "execvp" which can be used to
start another program replacing the current one.. if you want to
start another process you might want to use fork and then execvp
in windows there is WinExec( ) im' not sure about how to use it though
 
Old 07-25-2004, 12:17 AM   #3
gajaykrishnan
Member
 
Registered: Jul 2004
Posts: 65

Original Poster
Rep: Reputation: 15
it is a linux system and can take for eg. as
starting a web-browser for my c++ program without quitting it.
 
Old 07-25-2004, 12:43 AM   #4
gizmo_thunder
Member
 
Registered: Apr 2004
Posts: 101

Rep: Reputation: 15
check out the manual for execvp
man execvp
im' sure youll' be able to get the idea
 
Old 07-25-2004, 07:55 AM   #5
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
1) If you just want to execute a program, wait for it to finish, then continue your program:
Use system()

2) If you want to start a program that runs on its own while your program also continues to run:
Use fork() in combination with execvp()

3) If you want to run a program and read from its stdout into your program (or write to its stdin from your program) through a pipe:
Use popen()

See these man pages for more information:
man 3 system
man 2 fork
man 3 execvp
man 3 popen

If necessary, google for examples. One site that deals with this among other things, is the freely downloadable book (as PDF's + seperate sample code) "Advanced Linux Programming" (New Riders). Check http://www.advancedlinuxprogramming.com/

Last edited by Hko; 07-25-2004 at 07:57 AM.
 
  


Reply



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
help with usb application program nickster Programming 2 01-27-2005 02:42 AM
How to start an application when the fedora start ivonne Fedora 0 11-16-2004 12:16 PM
How to start an application when the fedora start ivonne Fedora 9 11-12-2004 01:40 PM
launching a program from a C++ application Error1312 Programming 7 02-25-2004 08:18 AM
Call Other Application by one Program kiennd Programming 4 08-02-2003 01:52 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:34 AM.

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