#### Archived

This topic is now archived and is closed to further replies.

# Command line parameters

This topic is 6053 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I posted this in general programming but got no response. So, one question? What are command line parameters?

##### Share on other sites
A command line parameter is an setting you pass to a program from the command line. For example back it the days of DOS if you typed:

C:\>dir

in a directory with thousands of files you couldn''t read the ones at the top because you could only fit about 25 lines on the screen, you could avoid this by giving the /p command line parameter to the program "dir" and it would display a single screen at a time e.g.

C:\>dir /p

##### Share on other sites
Command line parameters are parameters that are passed to an executable. For example, "ps -f" tells ps to give the full listing. Or, using halflife... "halflife.exe -console", tells the executable to enable the console in the game.
Implementing command line parameters is easy in c/c++ code.

  int main( int argc, char* argv[] ){#include ...do stuff with the command line parameters...return 1;}

argc is the number of parameters received, and argv contains a c-string representation of each of the parameters.

Edited by - DoomX on July 31, 2001 12:30:44 PM

##### Share on other sites
Windows programs can be run with command line parameters by just adding them after the filename in the Run dialog, or by creating a shortcut to them and modifying the path. You can make Visual C++ run your program with a command line parameter in the project settings if you want to test out command lines from within VC++.

Getting the command line parameters in a Win32 application is easy. The command line is passed in as an LPSTR when the program starts.