Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

command line parameters

Status
Not open for further replies.

scienzia

Programmer
Feb 21, 2002
160
0
0
IT
Hi,

I would like to know how to take parameters from command line running.

I mean I want to be able to run my application by DOS like this:

> MyApp -x -a

and get the parameters inside the application.


Thanks in advance.
 
the

int main(int argc, char* argv[])

method stores all command line arguments in the argv[] array

you can then access them the same way you would normally access members of an array, just make sure the parameter exists before you try and access it
 
I'm sorry my post missed some informations...

I'm talking abount MFC, and I didn't find anything similar to
Code:
int main(int argc, char* argv[])
[\code]
 

Check out the CCommandLineInfo class.

You can create a new class that inherits from this and add specific command line handlers by overriding the "ParseParam()" member function.

CMR
 
Hi,
you can use ::GetCommandLine() function
and then if you want you can convert the
LPSTR result to argv and argc with the
CommandLineToArgvW()

brgd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top