std::system - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::system

From cppreference.com
< cpp‎ | utility‎ | program

Defined in header `<cstdlib>` |  |
int system( const char *command ); |  |

Calls the host environment's command processor with command parameter. Returns implementation-defined value (usually the value that the invoked program returns).

If command is the NULL pointer, checks if host environment has a command processor and returns nonzero value only if the command processor exists.

### [edit] Parameters

command | - | character string identifying the command to be run in the command processor. If NULL pointer is given, command processor is checked for existence

### [edit] Return value

Implementation-defined value. If `command` is NULL returns nonzero value only if command processor exists.

### [edit] Notes

Related POSIX function popen makes the output generated by `command` available to the caller.

### [edit] Example

In this example there is a system call of the unix command ls -l >test.txt:

Run this code

    #include <cstdlib>

    int main()
    {
        std::system("ls -l >test.txt");
    }

### [edit] See also

C documentation for system

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/utility/program/system&oldid=65432"