Results 1 to 2 of 2

Thread: question re: system() command

  1. #1

    Thread Starter
    Lively Member fundean's Avatar
    Join Date
    Apr 2001
    Posts
    98

    question re: system() command

    Hello,

    I am trying to execute a program called "first.exe" which is located in a folder called c:\temp\programs.

    I get an error when trying to compile this:


    #include <iostream.h>
    #include <stdlib.h>

    void main()
    {

    system ("file:///c:\temp\programs\first.exe");
    }

    I can't seem to figure this one out --- any ideas would be most welcomed!
    Thanks

  2. #2
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403

    Re: question re: system() command

    In C/C++, the backslash character in a string is an escape character -- it tells the preprocessor that you are trying to specify a special character. For example, \t means tab, \n means new line, and so on. So when you want to use an actual backslash, you have you 'escape' it as well -- by putting a backslash in front of it:

    Code:
    system ("file:///c:\\temp\\programs\\first.exe");
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width