The meaning of "argc" and "argv" in programming

原创 2015年07月06日 17:23:48

We often find two parameters named "argc" and "argv" in main function like,

int main(int argc, char** argv)
{return 0;}

"argc" is the number of parameter we input in command line. "argv" saves all the paramters what we input.

A test demo code shows as follows:

#include <iostream>
using namespace std;
int main(int argc, char ** argv)
     int cnt;
    for (cnt=0; cnt<argc; cnt++)
        cout<<"Parameter "<<cnt<<" is " <<argv[i];
    return 0;

After I built this demo and generated a file named "demo.exe", I run this command in my terminal, and got the output like this:

demo.exe hello world !
Parameter 0 is demo.exe
Parameter 1 is hello
Parameter 2 is world
Parameter 3 is !

For different transaction types,What's the meaning of fields in MTL_MATERIAL_TRANSACTIONS

Account Receipt      Account Alias Receipt Cycle Count Adjust     Intransit Receipt  ...

Meaning of the buffers/cache line in the output of free


int _tmain(int argc, _TCHAR argv[]) 函数

  • 2013年12月15日 16:38
  • 559B
  • 下载

int main(int argc,char argv[ ])

  • 2012年03月26日 21:39
  • 17KB
  • 下载

The Evolution of Distributed Programming in R

By Paulin Shek Both R and distributed programming rank highly on my list of “good things”, so ima...

关于main函数的(int_argc,char_argv[ ])

  • 2011年04月10日 09:44
  • 27KB
  • 下载


  • 2012年02月20日 22:27
  • 451B
  • 下载

Part1:A Brief Study of Classes and Object-oriented Programming.

Actionscript 3.0 PV3d papervision3d OOP
  • pdcxs
  • pdcxs
  • 2011年07月15日 18:11
  • 61
您举报文章:The meaning of "argc" and "argv" in programming