C/Development/System Command

Материал из C\C++ эксперт
Перейти к: навигация, поиск

Call system command: dir

#include <stdlib.h>
int main(void)
{
  return system("dir");
}


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;
}