| Program termination | |||||||||||||||||||||
| |||||||||||||||||||||
| Unreachable control flow | |||||||||||||||||||||
(C23) | |||||||||||||||||||||
| Communicating with the environment | |||||||||||||||||||||
|
| ||||||||||||||||||||
| Memory alignment query | |||||||||||||||||||||
(C23) | |||||||||||||||||||||
| Signals | |||||||||||||||||||||
| Signal types | |||||||||||||||||||||
| Non-local jumps | |||||||||||||||||||||
| Types | |||||||||||||||||||||
Defined in header <stdlib.h> | ||
int system(constchar*command); | ||
Calls the host environment's command processor with the parametercommand. Returns an implementation-defined value (usually the value that the invoked program returns).
If command is a null pointer, checks if the host environment has a command processor and returns a nonzero value if and only if the command processor exists.
Contents |
| command | - | character string identifying the command to be run in the command processor. If a null pointer is given, command processor is checked for existence |
Implementation-defined value. Ifcommand is a null pointer, returns a nonzero value if and only if the command processor exists.
On POSIX systems, the return value can be decomposed usingWEXITSTATUS andWSTOPSIG.
The related POSIX functionpopen makes the output generated bycommand available to the caller.
In this example there is a system call of the unix commanddate +%A and a system call to (possibly installed)gcc compiler with command-line argument (--version):
#include <stdlib.h> int main(void){ system("date +%A"); system("gcc --version");}
Possible output:
Wednesdaygcc (GCC) 11.2.0...
C++ documentation forsystem |