Archived

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

GOD-CannoN

Command line parameters

Recommended Posts

xstreme2000    152
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 this post


Link to post
Share on other sites
DoomX    146
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 this post


Link to post
Share on other sites
Midnight Coder    122
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.

Share this post


Link to post
Share on other sites