Borland C++ reference

system

raw OCR

Issues a DOS command.

Defined in header <stdlib.h>

Syntax

#include <stdlib.h>
int system(const char "*command);

Portability

DOSUNIXWindowsANSI CC++ only
■■■

Remarks

system invokes the DOS COMMAND.COMfile 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 COMSPECenvironment variable is used to find the
COMMAND.COMfile, 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

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.