Another 'new' thing I've had to consider tonight:
int main(argc, char *argv[])
I can't see why I'd want to read in from the cmd line, but you never know! Why wouldn't I just use getline
and read it into a string? Or getch
if it were something else?
I suspect the answer is something to do with the amount of code to process - using something like this over #include <string>
is bound to use less computational power, correct?
EDIT: A year on looking back at this I feel pretty silly, had never really been taught about cmd line input for programs at university (I know right, what kinda course am I on..) :)
Being a games programmer, I can't see why I'd want to read in from the cmd line, but you never know!
Usually, for a GUI program, things passed in via command line tend to be hidden or debugging options.
For example, IE has a -k
command line switch that cannot be set in the normal preferences. That switch makes IE run in kiosk mode with lots of stuff disabled. This is something regular users should never want to do because if you run IE in kiosk mode you have no access to anything else (it's like turning Windows into MsIeOS).
Google chrome has a command line argument --first-run
that forces it to re-initialize the user preferences and pop up the first run settings dialog. This is very useful if you happen to corrupt your Chrome preferences.
Games are similar. Halo2 has a -windowed
command line argument that starts the game in a window instead of fullscreen. Here's a list of Halo2 command line arguments: http://support.microsoft.com/kb/830487
If you can't think of any use of command line arguments then don't use it. That doesn't mean that other people can't find a use for it.
For various programs, just google "[program name] command line arguments" to find out what, if any, there are. You'll find programs written by people who, like you, can't think of any use for command line arguments and so the programs don't have any.