Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

What's the meaning of 'argc' and 'argv' in C Language?

Not open for further replies.


Full Member level 5
Nov 16, 2006
Reaction score
Trophy points
Activity points
Please help me

i cant understand the meaning of 'argc' and 'argv' in the C Language

and what are there functions


C Language help

argc and argv are used when you are starting a program from the command line, or want to pass some variables to the program. (Dates back a bit!)
argc contains the number of arguments and argv is an array of pointers to the arguments which are strings. EG: char *argv[];
The first argument is always the programs name.
For example, if you had a program called 'squareroot'. You could call it by:
squareroot 4
squareroot would have 2 in argc and two pointers, one to "squareroot" and one to "4"
and it would return 2, (we hope!)

That is why main is declared as
int main(int argc, char *argv[]);

the return value is used by the calling program to see if the called program was ok.
There is another command line argument that sets enviroment variables, but that is only used by the real geeks and hackers.
C Language help

Argc is the number of arguments. Argv is an array (vector) holding pointers to the string arguments passed on the command line. There will be the same number of strings as argc indicates and can be accessed as argv[n], where n is a number between 1 and argc. argv[0] is treated special, in that it will contain the name of the program itself.

for (int n = 1; n < argc ; n++)
if (strncmp(argv[n],"magicword")==0)

C Language help

In C language there are no "argc" and "argv" reserved words. This come from examples from the books.
The guys before correctly explained those examples, but you could name them as follow:

int main(int count, char *garbage[])

and you will not find argc and argv in the code at all
or if you don't have parameters to you program then

int main()

Re: C Language help

argc and argv r useful to pass arguments at command prompt.

argc - it is counter to store how many arguments u r passing.
argv - is a 2D string array to store arguments.

there r not reserved words, u can choose ur own terms.

C Language help

argc contains the number of arguments and argv is an array of pointers to the arguments which are strings.

Not open for further replies.

Part and Inventory Search

Welcome to