Step Into Labs

Step Into C · Lesson 19 · Systems C

Command-Line Arguments

argc and argv, usage messages, stderr, exit codes and safe number parsing.

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

Missions

  1. Echo the arguments
  2. Usage and exit codes
  3. Numbers you can trust
  4. A real option parser