C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 05-29-2003, 05:10 PM   #1
mycro
Guest
 
Posts: n/a
Putting variables in SYSTEM

How would I put a variable in a system command.. like SYSTEM("talk VARIABLE")

??
Do I need a string?
Pls help thanks.
  Reply With Quote
Old 05-29-2003, 05:11 PM   #2
C++ Developer
 
XSquared's Avatar
 
Join Date: Jun 2002
Location: UWaterloo
Posts: 2,718
Use sprintf( ).

Code:
#include <cstdio>
#include <cstdlib>

int main( void ) {

    char *aString = "Hello";
    char buffer[ 256 ];

    sprintf( buffer, "test %s", aString );
    system( buffer );

}
__________________
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

Last edited by XSquared; 05-29-2003 at 05:14 PM.
XSquared is offline   Reply With Quote
Old 05-29-2003, 05:16 PM   #3
mycro
Guest
 
Posts: n/a
Would someone mind elaborating a little on that? Ive read up and cant get it.
  Reply With Quote
Old 05-29-2003, 07:59 PM   #4
mycro
Guest
 
Posts: n/a
Sorry im blind
  Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
esbo's data sharing example esbo C Programming 49 01-08-2008 11:07 PM
[question]Simulating the Reliability of a Component-Based System [with my code] burbose C Programming 4 06-13-2005 09:03 AM
[question]Simulating the Reliability of a Component-Based System burbose C Programming 3 06-13-2005 07:28 AM
Why Can't C++ Be Used to Develop Operating System? Antigloss C++ Programming 7 05-27-2005 06:16 AM
System Calls && Variables Okiesmokie C++ Programming 6 03-06-2002 09:10 PM


All times are GMT -6. The time now is 11:50 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22