The system() function allows you to run another program from within your code. The system() function's argument is a command that executes and then control returns to your program. The popen() function runs a command or process. Like the fopen() function is to a file, popen() opens and captures output from another program. The pclose() function closes a process after it has been opened.
- [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. …
- Working with arrays
- Building a structure
- Creating an array of structures
- Testing characters
- Working with strings in C
- Using pointers to manipulate data
- Manipulating files
- Using command-line arguments
- Working with time functions
Skill Level Intermediate
1. Arrays and Structures
2. Characters and Strings
4. Files and the Operating System
5. The Interesting and Extraordinary
Next steps1m 52s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.