GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::system(3) C++ Standard Libary std::system(3)

std::system - std::system


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


Calls the host environment's command processor (e.g. /bin/sh, cmd.exe, command.com)
with the parameter command. 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.


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


Implementation-defined value. If command 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 using WEXITSTATUS and WSTOPSIG


The related POSIX function popen makes the output generated by command available to
the caller.


An explicit flush of std::cout is also necessary before a call to std::system, if
the spawned process performs any screen I/O.

// Run this code


#include <cstdlib>
#include <fstream>
#include <iostream>


int main()
{
std::system("ls -l >test.txt"); // execute the UNIX command "ls -l >test.txt"
std::cout << std::ifstream("test.txt").rdbuf();
}


total 16
-rwxr-xr-x 1 2001 2000 8859 Sep 30 20:52 a.out
-rw-rw-rw- 1 2001 2000 161 Sep 30 20:52 main.cpp
-rw-r--r-- 1 2001 2000 0 Sep 30 20:52 test.txt

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.