C programming basics: Command line arguments

by amitsaha
GNU/Linux ◆ xterm-256color ◆ bash 1115 views

Learn the very basics of command line arguments.

You should realize that argc and argv are just variables. You can use any other variable names in their place. The important bit however is that you should always have the integer variable first, and then the array of arguments (which you can also declare as char *argv[] - i.e. an array of pointers).

The first argument is always the program name, i.e. ./prog in this case.

Feedback? I am @echorand