system function in c

What is system() in c programming?

system function in c is used to run Shell commands which cannot be directly executed by the c program.

This function is defined in stdlib.h header file.


int system(char const *COMMAND);

Return value

It returns status of the command or -1 on error.

Example program for system() in c

int main()
   printf("command processor is not present \n");
  return 0;


system in c output
system function in c output

Code explanation

The system() executes the shell command “ls”, if it is present on your system.

People Also Ask for

What does system() returns?

This function executes shell commands if they are present on your system.