Executes a command.
#include <process.h> | Required only for function declarations | |
#include <stdlib.h> | Use STDLIB.H for ANSI compatibilityint system( const char *command); | |
command | Command to be executed |
The system function passes command to the command interpreter, which executes the string as an operating-system command. The system function refers to the COMSPEC and PATH environment variables that locate the command-interpreter file (the file named COMMAND.COM in DOS). If command is a pointer to an empty string, the function simply checks to see whether or not the command interpreter exists.
If command is NULL and the command interpreter is found, the function returns a nonzero value. If the command interpreter is not found, it returns the value 0 and sets errno to ENOENT. If command is not NULL, the system function returns the value 0 if the command interpreter is successfully started.
A return value of –1 indicates an error, and errno is set to one of the following values:
Value | Meaning |
E2BIG | In DOS, the argument list exceeds 128 bytes, or the space required for the environment information exceeds 32K. |
ENOENT | The command interpreter cannot be found. |
ENOEXEC | The command-interpreter file has an invalid format and is not executable. |
ENOMEM | Not enough memory is available to execute the command; or the available memory has been corrupted; or an invalid block exists, indicating that the process making the call was not allocated properly. |
Standards:ANSI, UNIX
16-Bit:DOS
32-Bit:DOS32X
_exec functions, exit, _exit, _spawn functions
/* SYSTEM.C: This program uses system to TYPE its source file. */
#include <process.h>
void main( void )
{
system( "type system.c" );
}
/* SYSTEM.C: This program uses system to TYPE its source file. */
#include <process.h>
void main( void )
{
system( "type system.c" );
}