Command-Line Interaction

In this section, we’ll talk about how to interact with your computer via the terminal, a command line interface. The first lecture will show you how to use text-based commands to compile and run your program as well as a few more useful commands.

You can also enable your programs to use the command line. Up to this point in the course, if your programs have been collecting data or input from the user, it’s likely done so by using the get_ functions that are part of the CS50 Library. To that end, you can only collect information from the user as the program is running. Wouldn’t it be nice to collect input from the user before the program starts running, perhaps allowing the program to take different paths through the code depending on what the user provided at the command line? C has the capability to accept and process command-line arguments, and in this module we discuss what changes you need to make to your program(s) in order to work with them.