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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing command line arguments to a concole app?

Status
Not open for further replies.

TheMillionDollarMan

Programmer
Jun 10, 2002
132
US

Does anyone have some code snipet for this?
or
A key word I can use in the MS help?

Thanks

VC++ 6.0
Win2K
 
code:
Code:
#include <iostream>
using namespace std;

int
main(int argc, char **argv)
/* argc is total number of argument passed into this program. while argv is a pointer pointing to all the argument character string passed into here. the first argument is always the program name itself. */
{
   // print out the total number of argument to console.
   cout << argc << endl;
   for (register int i = 0; i < argc; i++)
      /* print out every argument passed. the first argument must be the program name (retrived by argv[0] or else.). */
      cout << &quot;argument [&quot; << i << &quot;] == &quot; << argv[i] << endl;
   return 0;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top