Access command line parameters - C++ Function

C++ examples for Function:main function

Description

Access command line parameters

Demo Code

#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
   int i;//w ww.ja v  a2 s.c  o m
   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;
}

Result


Related Tutorials