De RAD Studio
Aller à : navigation, rechercher

Remonter à stdlib.h - Index

Header File



extern int _argc;


_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.


#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.