Thread: System Function

  1. #1
    Registered User
    Join Date
    Oct 2001

    Question System Function

    How can I use a variable in my system function? I want to pass the system time into a bacth file I'm calling from the program.



  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    You need to take the variable and place it in a string that contains the system call you wish to use. For example, if you want to open a user defined file in a program defined directory, you would paste the user defined string onto the program defined string:
    strcat ( progDefined, userDefined );

    Or you could use sprintf to fill a buffer and then use that buffer to make the system call:
    sprintf ( buffer, "%s%s", progDefined, userDefined );
    system ( buffer );

    Take a look at the sprintf function for further details.

    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-13-2011, 08:28 AM
  2. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. measuring system resources used by a function
    By Aran in forum C Programming
    Replies: 1
    Last Post: 03-13-2006, 05:35 PM
  5. I need help with passing pointers in function calls
    By vien_mti in forum C Programming
    Replies: 3
    Last Post: 04-24-2002, 10:00 AM