O'Reilly logo

Linux® Programming by Example by Arnold Robbins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. Arguments, Options, and the Environment

In this chapter

  • 2.1 Option and Argument Conventions page 24

  • 2.2 Basic Command-Line Processing page 28

  • 2.3 Option Parsing: getopt() and getopt_long() page 30

  • 2.4 The Environment page 40

  • 2.5 Summary page 49

  • Exercises page 50

Command-line option and argument interpretation is usually the first task of any program. This chapter examines how C (and C++) programs access their command-line arguments, describes standard routines for parsing options, and takes a look at the environment.

Option and Argument Conventions

The word arguments has two meanings. The more technical definition is “all the ’words’ on the command line.” For example:

$ ls main.c opts.c process.c

Here, the user typed four “words.” All four words ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required