Thread: Putting variables in SYSTEM

  1. #1
    mycro
    Guest

    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.

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    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 );
    
    }
    Last edited by XSquared; 05-29-2003 at 05:14 PM.
    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

  3. #3
    mycro
    Guest
    Would someone mind elaborating a little on that? Ive read up and cant get it.

  4. #4
    mycro
    Guest
    Sorry im blind

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. esbo's data sharing example
    By esbo in forum C Programming
    Replies: 49
    Last Post: 01-08-2008, 11:07 PM
  2. Replies: 4
    Last Post: 06-13-2005, 09:03 AM
  3. Replies: 3
    Last Post: 06-13-2005, 07:28 AM
  4. Why Can't C++ Be Used to Develop Operating System?
    By Antigloss in forum C++ Programming
    Replies: 7
    Last Post: 05-27-2005, 06:16 AM
  5. System Calls && Variables
    By Okiesmokie in forum C++ Programming
    Replies: 6
    Last Post: 03-06-2002, 09:10 PM