Thread: The sytem(); function

  1. #16
    Registered User
    Join Date
    Jul 2007
    Location
    Texas
    Posts
    103
    Does anyone know where I can find a manual page for the system(); function? I can't find one. Usually it is just a "man fgets()" google away, only in this case system. But I can't find anything on it.

  2. #17
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    If you have access to a copy of the C standard, you can find it there.

    You could also refer to online references like cppreference.com's system entry. Speaking of man though, I found this.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #18
    Registered User
    Join Date
    Jul 2007
    Location
    Texas
    Posts
    103
    Well, thats weird because the 2nd link I actually went to that site and searched, I guess I just over looked it. Well, I still can't figure out the return value. Because eveytime I try to compile I get an error. Could someone paste a simple piece of code or help me out. I just need to figure out how to get the return value.

  4. #19
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Because eveytime I try to compile I get an error.
    What error do you get?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #20
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Code:
    #include <stdlib.h>
    
    int main ()
    { 
      int ret = system("1.bat");
      return 0;
    }
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  6. #21
    Registered User
    Join Date
    Jul 2007
    Location
    Texas
    Posts
    103
    Ah, you are a god. I feel like a total moron looking at that. But thank you very much.

  7. #22
    Registered User
    Join Date
    Mar 2008
    Posts
    3
    how about this???

    for windows 9X:
    system("C\\Windows\\Desktop\\filename.exe");

    for windows NT:
    system("C\\Winnt\\Desktop\\filename.exe");

    for windows XP:
    system("C\\Document and Settings\\Current User\\Desktop\\filename.exe");

    for windows VISTA:
    system("C\\Users\\Current User\\Desktop\\filename.exe");

  8. #23
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    And how are you going to determine which operating system the user is running? And what about colons, like C:?

    It should be noted that separate system() calls are independent of one another. Each system() call starts its own shell, which, in addition to being quite inefficient, means that calling system("cd whatever") will have no effect whatsoever on any system() calls following it.

    The non-standard chdir() can be used to change the directory. I'm not sure what the Windows equivalent is.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  3. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM