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 - C Tutorial
From the course: C: Data Structures, Pointers, and File Systems
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
Reading from a file3m 25s
-
(Locked)
Writing to a file3m 24s
-
(Locked)
Working with raw data2m 53s
-
(Locked)
Using random file access2m 47s
-
(Locked)
Manipulating files2m 57s
-
(Locked)
Exploring the path2m 8s
-
(Locked)
Reading a directory2m 53s
-
(Locked)
Getting file information2m 46s
-
(Locked)
Using command line arguments2m 44s
-
(Locked)
Calling the operating system2m 46s
-
(Locked)
Challenge: Read and store filenames1m 6s
-
(Locked)
Solution: Read and store filenames2m 52s
-
-
-