Skip to main content
gamedev.net
🔒 Locked

Command Line Parameters

Started by Run_The_Shadows 1 reply 300+ views
Original Post
Run_The_Shadows
Run_The_Shadows
This has nothing to do with any project i''m working on, but I was just curious. How the heck do you allow for command line parameters in your program, and make it recognize them? This RtS-Babble© has been brought to you by: -Run_The_Shadows -Run_The_Shadows@excite.com
SiCrane
SiCrane
It depends on what you''re using to program your application.

For example if you''re using standard C/C++ your entry point, main has arguments argc and argv. argv contains the command line arguments already broken up, and argc contains the number of command line arguments. So if you want sound enabled only if one of your arguments is "-S" then loop through the argv entries and strcmp against "-S" when initializing sound.

If you''re using VCL, the command line arguments are parsed and placed in ParamStr(), MFC uses a CCommandLineInfo class attached to CWinApp. A straight Win32 app gets passed the command line as a string to WinMain.
clonemaker
clonemaker
In windows you can also do this.

extern "C" int __argc;
extern "C" char** __argv;

#define argc __argc
#define argv __argv

This way you can use standard c methods to acess the command line.


cmaker- I do not make clones.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.