English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

What do argc and argv stand for? What is their function and why are they named that way.

2006-11-26 03:18:03 · 4 answers · asked by Shaina B 1 in Computers & Internet Programming & Design

4 answers

That's C(++), isn't it?
Well, argc is the number of arguments you enter into the command line. Argv is a vector pointing to the arguments themselves. Argv[0] is the name the program is called.
Here an example I know it from C:

main(int argc, char *argv[]) {
...
}

So you see, argc has to be an integer and argv a vector pointer. If you now enter the following:

program test1.txt res1.txt

you get:

argc = 3
argv[0] = program.exe (with path)
argv[1] = test1.txt
argv[2] = test2.txt

2006-11-26 03:31:00 · answer #1 · answered by nightgirl1200 4 · 0 0

The name of the variable argc stands for "argument count"; argc contains the number of arguments passed to the program. The name of the variable argv stands for "argument vector". A vector is a one-dimensional array, and argv is a one-dimensional array of strings. Each string is one of the arguments that was passed to the program.

Good luck and Happy Computing!

2006-11-26 11:20:58 · answer #2 · answered by Anonymous · 0 0

argc: argument count
argv: argument values

2006-12-04 07:12:05 · answer #3 · answered by (ADD) 1 · 0 0

'c' stands for counter and 'v' stands for vector.

2014-01-30 03:38:39 · answer #4 · answered by kalakanti 1 · 0 0

fedest.com, questions and answers