system
raw OCR
Issues a DOS command.
Defined in header <stdlib.h>
Syntax
#include <stdlib.h>
int system(const char "*command);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ | ■ |
Remarks
| system invokes the DOS COMMAND.COM | file to execute a DOS |
command, batch file, or other program named by the string command, from inside an executing C program.
To be located and executed, the program must be in the current directory or in one of the directories listed in the PATH string in the environment.
| The COMSPEC | environment variable is used to find the |
| COMMAND.COM | file, so that file need not be in the current directory. |
Return value
If command is a NULL pointer, then system returns nonzero if a command processor is available. If command is not a NULL pointer, system returns zero if the command processor was successfully started. If an error
| occurred, a -1 is returned and errno is set to ENOENT, | ENOMEM, | E2BIG, |
or ENOEXEC.
See also
exec_fpresetsearchpathspawn
Example
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
printf("About to spawn command. com and run a DOS command\n");
system!"dir");
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/stdlib.h/system/
· short form /3.1/system/