Skip to Main Content
Linux Application Development, Second Edition
book

Linux Application Development, Second Edition

by Michael K. Johnson, Erik W. Troan
November 2004
Intermediate to advanced content levelIntermediate to advanced
736 pages
14h 4m
English
Addison-Wesley Professional
Content preview from Linux Application Development, Second Edition

Chapter 26. Parsing Command-Line Options

Most Linux programs allow the user to specify command-line options. Such options perform a wide variety of functions but are fairly uniform in their syntax. Short options consist of a - character followed by a single alphanumeric character. Long options, common in GNU utilities, consist of two - characters followed by a string made up of letters, numbers, and hyphens. Either type of option may be followed by an argument. A space separates a short option from its arguments; either a space or an = separates a long option from an argument.

There are many ways of parsing command-line options. The most popular method is parsing the argv array by hand. The library functions getopt() and getopt_long() provide some ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux System Programming, 2nd Edition

Linux System Programming, 2nd Edition

Robert Love

Publisher Resources

ISBN: 0321219147Purchase book