Execute a command.
int system( const char *command ); int _wsystem( const wchar_t *command );
Command to be executed.
If command is NULL and the command interpreter is found, returns a nonzero value. If the command interpreter is not found, returns 0 and sets errno to ENOENT. If command is not NULL, system returns the value that is returned by the command interpreter. It returns the value 0 only if the command interpreter returns the value 0. A return value of – 1 indicates an error, and errno is set to one of the following values:
Argument list (which is system dependent) is too big.
Command interpreter cannot be found.
Command-interpreter file has invalid format and is not executable.
Not enough memory is available to execute command; or available memory has been corrupted; or invalid block exists, indicating that process making call was not allocated properly.
See _doserrno, errno, _sys_errlist, and _sys_nerr for more information on these, and other, return codes.
The system function passes command to the command interpreter, which executes the string as an operating-system command. system refers to the COMSPEC and PATH environment variables that locate the command-interpreter file (the file named CMD.EXE in Windows 2000 and later). If command is NULL, the function simply checks to see whether the command interpreter exists.
You must explicitly flush (using fflush or _flushall) or close any stream before calling system.
_wsystem is a wide-character version of system; the command argument to _wsystem is a wide-character string. These functions behave identically otherwise.
TCHAR.H routine
_UNICODE & _MBCS not defined
_MBCS defined
_UNICODE defined
_tsystem
system
_wsystem
Routine
Required header
<process.h> or <stdlib.h>
<process.h> or <stdlib.h> or <wchar.h>
For additional compatibility information, see Compatibility in the Introduction.
This program uses system to TYPE a text file.
// crt_system.c #include <process.h> int main( void ) { system( "type crt_system.txt" ); }
Line one. Line two.
System::Diagnostics::ProcessStartInfo Class
System::Diagnostics::Process Class