Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      system

      From cppreference.com
      <c‎ |program
       
       
      Program support utilities
      Program termination
      Unreachable control flow
      Communicating with the environment
      system

      Memory alignment query
      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

      [edit]Parameters

      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

      [edit]Return value

      Implementation-defined value. Ifcommand is a null pointer, returns a nonzero value if and only if the command processor exists.

      [edit]Notes

      On POSIX systems, the return value can be decomposed usingWEXITSTATUS andWSTOPSIG.

      The related POSIX functionpopen makes the output generated bycommand available to the caller.

      [edit]Example

      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):

      Run this code
      #include <stdlib.h> int main(void){    system("date +%A");    system("gcc --version");}

      Possible output:

      Wednesdaygcc (GCC) 11.2.0...

      [edit]References

      • C17 standard (ISO/IEC 9899:2018):
      • 7.22.4.8 The system function (p: 257)
      • C11 standard (ISO/IEC 9899:2011):
      • 7.22.4.8 The system function (p: 353-354)
      • C99 standard (ISO/IEC 9899:1999):
      • 7.20.4.6 The system function (p: 317)
      • C89/C90 standard (ISO/IEC 9899:1990):
      • 4.10.4.5 The system function

      [edit]See also

      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=c/program/system&oldid=140333"

      [8]ページ先頭

      ©2009-2025 Movatter.jp