The arguments of entry-point function
main
come not from your code, but from the user.
Say, if the user enters
yourApplication 8080
or
yourApplication -port:8080
it means that the
main
function is called with
argc == 1
; and
argv[]
will be the string containing port number of the option string like "-port:8080". It's up to you to check up the value of
argc
and parse the array of strings based on some assumptions on the command line input, which you should also document for the user.
You can have any number of arguments, variable number of arguments, and so on. Look how some available console-only utilities work with command line — such applications are very typical for Linux and UNIX-like OS.
—SA