_argc

From Appmethod Topics
Jump to: navigation, search

Go Up to stdlib.h Index


Header File

stdlib.h

Syntax

extern int _argc;

Description

_argc has the same value as argc (passed to main) when the program starts. This variable holds the number of arguments passed to the program. The value includes the name of the program itself, so _argc and argc are always at least 1.

Example

#include <iostream>
#include <stdlib.h>     // TO GET THE GLOBAL _arg VALUES

using namespace std;

void func()
{
   cout << "argc= " << _argc << endl;

   for (int i = 0; i < _argc; ++i)
      cout << _argv[i] << endl;
}

void main(int argc, char ** argv)
{
   func(); // func can get the program arguments from global variables.
}