Execute system command: dir, copy and so on : System Command « Development « C / ANSI-C






Execute system command: dir, copy and so on


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

int main ()
{
  int res;
  
  puts ("Trying to execute command DIR");
  
  res = system ("dir");
  
  if (res == -1) 
      puts ("Error executing DIR");
  else 
      puts ("Command successfully executed");
  
  return 0;
}


           
       








Related examples in the same category

1.Call system command: dirCall system command: dir