LinuxQuestions.org
Visit Jeremy's Blog.
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 09-07-2005, 03:51 PM   #1
twirl
Member
 
Registered: Aug 2005
Posts: 168

Rep: Reputation: 15
system() and execl anyone got any sample code please?


Hi,

i have worked my way through my c++ book but it dont cover what i need to finish my program, i have been told i will need to use system() or execl for my program. (1.) I need to be able to ask user for file to open and be able to open that file for editing and then save and return back to menu when done. 2. I need to be able to execute the path from games.db (like say line 1 is /home/twirl/bf1942/start.sh i need it to execute that line and so forth depending on how many lines are in games.db and what the user wishes to run. (sourcode at http://pastebin.com/356387 ) and i was wondering if anyone could tell me or show me a sample of code please?

Thankyou
 
Old 09-07-2005, 05:13 PM   #2
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
Using system is really very simple:
Code:
char buf[256];

sprintf(buf, "some_program %s", filename);
system(buf);
 
Old 09-08-2005, 02:01 AM   #3
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Please see these threads:
http://www.linuxquestions.org/questi...hreadid=282078
http://www.linuxquestions.org/questi...hreadid=288546
http://www.linuxquestions.org/questi...hreadid=326699
 
  


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
Using sample C++ code from a book...won't compile Baix Programming 4 03-05-2005 02:04 PM
Perl: What's this mean? (Code sample) Benr Programming 5 10-23-2004 07:20 AM
Open Firmware code for booting OS from SATA : sample code available somewhere ? drsparikh Linux - Hardware 0 03-12-2004 11:16 AM
Sample code to build a window with slider bar? NewComer Programming 3 02-12-2004 01:34 PM
Any sample code of how to use Rand_seed() cybercop12us Programming 0 04-03-2003 07:25 AM

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

All times are GMT -5. The time now is 11:25 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