Step Into C · Lesson 19 · Systems C
Command-Line Arguments
argc and argv, usage messages, stderr, exit codes and safe number parsing.
- ~30 minreading and coding
- 4missions
- membersaccess
- Clanguage
Part of Step Into C. The full lesson, its missions and the real compiler and debugger are in the course. Try a free lesson first to see how it works.
Every tool you run from a terminal receives arguments: gcc main.c -o main, ping -n 4 host, git commit -m "msg". In C they arrive as parameters of main:
In this lesson
- Programs take arguments
- What argv looks like in memory
- Walking the arguments
- stdout, stderr and exit codes
- Arguments are text: converting numbers
- Parsing options
Missions
- Echo the arguments
- Usage and exit codes
- Numbers you can trust
- A real option parser