Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>system() execute dos command</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 system()                Execute DOS Command

 #include  <stdlib.h>
 #include  <process.h>

 int        system(string);
 const char *string;                     Command to be executed

    system() passes 'string' to the command interpreter COMMAND.COM.
    'string' is then executed as if it had been typed at the DOS prompt.

       Returns:     0, if successful. -1 if error.

         Notes:     system() uses the COMSPEC and PATH environment
                    variables to locate COMMAND.COM.

   -------------------------------- Example ---------------------------------

    The following statements send a directory listing to the file
    "dir.txt":

           #include <stdlib.h>     /* for 'system' */
           #include <stdio.h>       /* for 'printf' */

           main()
           {
               int result;

               result = system("dir >> dir.txt");
               if (result == -1)
                   printf("error executing system command\n");
           }


See Also: exec...() spawn...()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson