diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/c/program%2Fsystem.html | |
new repository
Diffstat (limited to 'devdocs/c/program%2Fsystem.html')
| -rw-r--r-- | devdocs/c/program%2Fsystem.html | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/devdocs/c/program%2Fsystem.html b/devdocs/c/program%2Fsystem.html new file mode 100644 index 00000000..40e60354 --- /dev/null +++ b/devdocs/c/program%2Fsystem.html @@ -0,0 +1,33 @@ + <h1 id="firstHeading" class="firstHeading">system</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code><stdlib.h></code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl"> <td class="t-dcl-nopad"> <pre data-language="c">int system( const char *command );</pre> +</td> <td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> </table> <p>Calls the host environment's command processor with the parameter <code>command</code>. Returns an implementation-defined value (usually the value that the invoked program returns).</p> +<p>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.</p> +<h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> command </td> <td> - </td> <td> character string identifying the command to be run in the command processor. If a null pointer is given, command processor is checked for existence </td> +</tr> +</table> <h3 id="Return_value"> Return value</h3> <p>Implementation-defined value. If <code>command</code> is a null pointer, returns a nonzero value if and only if the command processor exists.</p> +<h3 id="Notes"> Notes</h3> <p>On POSIX systems, the return value can be decomposed using <a rel="nofollow" class="external text" href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/wait.html"><code>WEXITSTATUS</code> and <code>WSTOPSIG</code></a>.</p> +<p>The related POSIX function <a rel="nofollow" class="external text" href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/popen.html">popen</a> makes the output generated by <code>command</code> available to the caller.</p> +<h3 id="Example"> Example</h3> <p>In this example there is a system call of the unix command <b>date +%A</b> and a system call to (possibly installed) <b>gcc</b> compiler with command-line argument (<i>--version</i>):</p> +<div class="t-example"> <div class="c source-c"><pre data-language="c">#include <stdlib.h> + +int main(void) { + system("date +%A"); + system("gcc --version"); +}</pre></div> <p>Possible output:</p> +<div class="text source-text"><pre data-language="c">Wednesday +gcc (GCC) 11.2.0 +...</pre></div> </div> <h3 id="References"> References</h3> <ul> +<li> C17 standard (ISO/IEC 9899:2018): </li> +<ul><li> 7.22.4.8 The system function (p: 257) </li></ul> +<li> C11 standard (ISO/IEC 9899:2011): </li> +<ul><li> 7.22.4.8 The system function (p: 353-354) </li></ul> +<li> C99 standard (ISO/IEC 9899:1999): </li> +<ul><li> 7.20.4.6 The system function (p: 317) </li></ul> +<li> C89/C90 standard (ISO/IEC 9899:1990): </li> +<ul><li> 4.10.4.5 The system function </li></ul> +</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/utility/program/system" title="cpp/utility/program/system">C++ documentation</a></span> for <code>system</code> </td> +</tr> </table> <div class="_attribution"> + <p class="_attribution-p"> + © cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br> + <a href="https://en.cppreference.com/w/c/program/system" class="_attribution-link">https://en.cppreference.com/w/c/program/system</a> + </p> +</div> |
