system - C stdlib.h

C examples for stdlib.h:system

Type

function

From


<cstdlib>
<stdlib.h>

Description

Execute system command

Prototype

int system (const char* command);

Parameters

Parameter Description
command C-string system command

Demo Code

#include <stdio.h>
#include <stdlib.h>

int main ()/*ww w. jav a  2 s  .c o m*/
{
  int i;
  printf ("Checking if processor is available...");
  if (system(NULL))
     puts ("Ok");
  else
     exit (EXIT_FAILURE);

  i=system ("cd a");
  //i=system ("dir");
  printf ("The value returned was: %d.\n",i);
  return 0;
}

Related Tutorials