C++ Command line tool - Issue other CLI commands

Discussion in 'Mac Programming' started by hiddenpremise, Jan 13, 2009.

  1. hiddenpremise macrumors regular

    hiddenpremise

    Joined:
    Jul 25, 2008
    Location:
    Somewhere between my imagination and reality
    #1
    I have created a new project in xCode 2 that is a command line tool. Does anyone know how to issue command line commands from a c++ command line tool?

    What I am trying to do is write a c++ command line tool that will issue the "zip -r" command and backup a set of files. My motives are just to learn how to issue command line commands from a c++ program.

    Thanks,
    Whit
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    I think the easiest would be the system() function.
     
  3. hiddenpremise thread starter macrumors regular

    hiddenpremise

    Joined:
    Jul 25, 2008
    Location:
    Somewhere between my imagination and reality
    #3
    What ".h" file would contain the system() class?
     
  4. toddburch macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #4
    Per Xcode -> Help -> Documentation, and typing in "system" in the search field, it tells you <stdlib.h>.
     
  5. hiddenpremise thread starter macrumors regular

    hiddenpremise

    Joined:
    Jul 25, 2008
    Location:
    Somewhere between my imagination and reality
    #5
    <---xcode noob :)

    Thanks much for your help. Zip doesn't work through the system command, but I can get other things to work, so I'm happy.
     
  6. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #6
    It should. Are you setting the working directory?
     

Share This Page