From the course: C: Data Structures, Pointers, and File Systems

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Calling the operating system

Calling the operating system - C Tutorial

From the course: C: Data Structures, Pointers, and File Systems

Start my 1-month free trial

Calling the operating system

- [Instructor] For those times that your program can't do everything or you see no point in reinventing the digital wheel, you can run another program from inside your own. The first and most popular way to pass off control to another program is to use the system function, as shown in this code. The function is prototyped in the stdlib header file, included at line two. At line nine, that system function passes a command to the operating system as an argument. Here, I've specified the clear screen command, whish is cls for Windows or clear for the Unix shell, in lines eight and nine. Now, ensure that the proper statement is enabled for your operating system. This is Windows, so the Unix version is disabled at line eight. Build and run. Press enter to clear the screen. The system command issued the clear screen command, which cleared the screen, and my program said thank you. The system function runs a command and then returns to your program. When the command's output is important to…

Contents