Getting Input from the Command Line

Up to this point, we have not read any input for any of our programs from any source. All program data has been hardcoded in the program itself. In this chapter, we will begin exploring programming input with one of the simplest available methods—inputting from the console's command line.

We will revisit the main() function with our added knowledge of function parameters and arrays of strings. We will then explore how to retrieve strings via an argument to the main() function.

The following topics will be covered in this chapter:

  • Understanding the two forms of main()
  • Understanding how argc and argv are related
  • Writing a program to retrieve values from argv and print them

Technical requirements

Continue ...

Get Learn C Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.