C++ main() Access command line parameters

Description

C++ main() Access command line parameters

#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
   int i;//from w w  w .  j av  a 2s.c om
   cout << "\nThe number of items on the command line is " << argc << endl << endl;
   for (i = 0; i < argc; i++)
   {
      cout << "The address stored in argv[" << i <<"] is " << int(argv[i]) << endl;  // display address as an integer number
      cout << "The character pointed to is " << *argv[i] << endl;
   }
   return 0;
}



PreviousNext

Related