int  system ( const char * command );

Execute command.
  Invokes command interpreter to execute a command. Once terminated, the interpreter gives back control to the program returning an int value.


Null-terminated string containing the system command to be executed.

Return Value.
  If a command was successfully executed the command interpreter returns an adequate value; generally 0 indicates that the action performed by the command interpreter terminated with no errors.
  A return value of -1 indicates an error, and global variable errno is set to one of the following errors:

ENOENTCommand interpreter not found
ENOEXECCommand interpreter is not executable
ENOMEMError allocating memory for the process
E2BIGArgument list too big

  Defined in ANSI-C.
  Return value and possible errno values are system dependent.


/* system example : DIR */
#include <stdio.h>
#include <stdlib.h>

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

See also.
  atof, strtol, strtoul

© The C++ Resources Network, 2000