The system() function directs your program to run another program or to issue a command. For example:
system("dir");
The preceding statement directs the operating system to issue the dir command.
The following code shows how to use two system() functions.
#include <stdio.h> #include <stdlib.h> int main() //www . ja v a 2 s . c o m { printf("Press Enter to list the file:"); getchar(); system("dir"); /* Windows only */ //system("clear"); /* Mac - Unix */ puts("That's better"); return(0); }
The code includes the stdlib.h header file, which is required for the system() function to work.