How to call another program?

This is a discussion on How to call another program? within the C++ Programming forums, part of the General Programming Boards category; Can anyone tell me the code to call another program? Here's an example: --- Enter selection: 1, 2, 3: 3 ...

  1. #1
    Registered User Unreg1stered's Avatar
    Join Date
    Jul 2002
    Posts
    25

    How to call another program?

    Can anyone tell me the code to call another program? Here's an example:

    ---
    Enter selection: 1, 2, 3: 3 (when I enter 3)
    the program will execute: notepad.exe ...etc.

    Thanks.

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    check the FAQ, under running execs.

    http://www.cprogramming.com/boardfaq.html
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Look these up in MSDN

    system
    _spawnl
    CreateProcess

    http://msdn.microsoft.com

  4. #4
    Registered User Unreg1stered's Avatar
    Join Date
    Jul 2002
    Posts
    25
    Thank you. I think I found it, but it doesn't work when I try it. Do I do something wrong here?

    Code:
    #include <stdlib.h>
    
    int main()
    {
      system ("c:\windows\notepad.exe");
      return 0;
    }
    When I execute the code, it said "bad command or file name". I believe it's the path that I use. Can you tell me how to use the path in the system(" "); ?

    ty
    Last edited by Unreg1stered; 07-20-2002 at 11:58 PM.

  5. #5
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    instead of this:
    Code:
    system ("c:\windows\notepad.exe")
    try this
    Code:
    system ("c:\\windows\\notepad.exe")

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function call is crashing program
    By Shaun32887 in forum C++ Programming
    Replies: 4
    Last Post: 07-17-2008, 03:18 AM
  2. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. making a phone call in a program
    By jverkoey in forum C++ Programming
    Replies: 1
    Last Post: 03-18-2004, 04:09 PM
  5. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 11:39 AM

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