devxlogo

Interacting With the Operating System Directly

Interacting With the Operating System Directly

In general, API functions and classes enable you to interact with the operating system. Sometimes, however, it is much simpler to execute a system command directly. For this purpose, you can use the standard function system() that takes a const char * argument containing a shell command. For example, on a DOS/Windows system, you can display the files in the current directory like this:

 #include using namespace std;int main(){  system("dir");  //execute the "dir" command}  

devx-admin

Share the Post: