argc and argv

I've seen this a lot. I've watched a couple of videos. I know the first one is number of arguments, I think, and second is an array containing the arguments, but what are some practical uses for having a main function with arguments?
Ever used the command line to do anything other than start a GUI? How about the well known commands for copying a file:

cp ~/someFile.txt /media/backup.txt
The arguments used to identify the source file and destination. There are, of course, a bazillion such command line programs with command line options.

How about switches and controls on programs?

g++ -c -lsomeLibrary code.cpp
Creating a static library from code.cpp and specifying a library to link against

./someGuiProgram -safeMode
Starting a GUI based program, but adding a command to change the options - there are many, many of these. You might be surprised how many of the programs you normally start by clicking a mouse button have extra options you've never known about.
Last edited on
Topic archived. No new replies allowed.