System () function in C
The int system (const char * command) function passes the command name or program name specified by the command to the host environment to be executed by the Command processor and returned after the command is completed.
The int system (const char * command) function passes the command name or program name specified by the command to the host environment to be executed by the Command processor and returned after the command is completed.
Declare the system () function in C
Below is the declaration for system () in C:
int system ( const char * command )
Parameters
command : This is the string containing the command name.
Returns the value
The value is returned to -1 if there is an error, and if successful, returns the state of the command.
For example
The following C program illustrates how to use the system () function to list all files and directories in the current directory on a Windows device:
#include #include #include int main () { char command [ 50 ]; strcpy ( command , "dir" ); system ( command ); return ( 0 ); }
Compile the C program in the Window environment to see the result.
According to Tutorialspoint
Previous article: Function getenv () in C
Next lesson: Function bsearch () in C
4 ★ | 1 Vote
You should read it
- Free () function in C
- Calloc () function in C
- The function atexit () in C
- The exit () function in C
- The abort () function in C
- Call the function by pointer in C ++
- Function realloc () in C
- Malloc () function in C
- The function gets () in C
- The getchar () function in C
- Function abs () in C
- Function fputs () in C
Maybe you are interested
What to do when open command window here does not appear?
How to switch users on the Linux command line
How to fix Mac Homebrew error 'zsh: command not found: brew'
What is the Command key on Windows?
How to use read command in Linux
Basic Linux commands everyone needs to know - Operations on Linux are much faster