A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/cstdlib/system/ below:

function

<cstdlib>

system
int system (const char* command);

Execute system command

Invokes the command processor to execute a command.

If command is a null pointer, the function only checks whether a command processor is available through this function, without invoking any command.

The effects of invoking a command depend on the system and library implementation, and may cause a program to behave in a non-standard manner or to terminate.



Parameters
command
C-string containing the system command to be executed.
Or, alternatively, a null pointer, to check for a command processor.

Return Value If command is a null pointer, the function returns a non-zero value in case a command processor is available and a zero value if it is not.

If command is not a null pointer, the value returned depends on the system and library implementations, but it is generally expected to be the status code returned by the called command, if supported.



Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* system example : DIR */
#include <stdio.h>      /* printf */
#include <stdlib.h>     /* system, NULL, EXIT_FAILURE */

int main ()
{
  int i;
  printf ("Checking if processor is available...");
  if (system(NULL)) puts ("Ok");
    else exit (EXIT_FAILURE);
  printf ("Executing command DIR...\n");
  i=system ("dir");
  printf ("The value returned was: %d.\n",i);
  return 0;
}

Data races The function accesses the array pointed by command.
Concurrently calling this function with a null pointer as argument is safe. Otherwise, it depends on the system and library implementation.

Exceptions (C++)No-throw guarantee: this function does not throw exceptions.

If command is not a null pointer, it causes undefined behavior.



See also
exit
Terminate calling process (function)
getenv
Get environment string (function)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4