How to Excute System Commands in C

on Monday, February 21, 2011
 /* system example : DIR */  
 #include <stdio.h>  
 #include <stdlib.h>  
 int main ()  
 {  
  int i;  
  //printf ("Checking if processor is available...");  
  if (system(NULL)) puts ("Ok");  
  else exit (1);  
  printf ("Executing command dir...\n");  
  i=system ("dir"); // put ls if you are using linux  
  printf ("The value returned was: %d.\n",i);  
  return 0;  
 }