answersLogoWhite

0

Difference between argc and argv

Updated: 10/18/2022
User Avatar

Wiki User

13y ago

Best Answer

I really hope you pay more attention to your texts and lessons in the future, anyway:

int argc (Argument Count, note that it is an integer.)

char* argv[] (Argument Value, the actual thing stored there.)

Those are passed to the main function from the operating system so that you can have command line parameters.

Oh and if you really want me to blow your mind, they don't need to be name argc/argv.

int main(int argc, char* argv[])

{

for(a=0;a<=argc;a++){

printf(%s,argv[a]);

}

return 0;

}

is the same as

int main (int foo, char* bar[])

{

for(a=0;a<=foo;a++){

printf(%s,bar[a])

}

return 0;

}

(Which means the prototype for main is usually: int main(int, char**) )

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Difference between argc and argv
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is an example of a parameter?

'argc' and 'argv' in this line: int main (int argc, char **argv)


Wap of function call by value?

This 'question' is not a question, but here you are. int main (int argc, char **argv) { printf ("argc=%d argv=%p\n", argc, argv); return 0; }


Are the variables argc and argv are local to main?

Answeryes they are local to mainAnswerargc and argv can be used as variable names anywhere in a C program. If they are declared as arguments to main() then they are local to main:int main(int argc, char *argv[]){// argc and argv are local to main in this short programreturn 0;}


What does char argv mean?

The full form of this is: char* argv[]; Where argv is a pointer to a null-terminated array of null-terminated strings. We use this type of argument to pass command line switches to the main function: int main (char * argv[], int argc); The names of these arguments, argv and argc, are conventional. The argc argument tells us how many elements are in the argv argument, such that argv[0] is the full-qualified name of the executable and argv[argc] is the null-terminator of the array. Any and all other elements (argv[n], such that 0&lt;n&lt;argc) represent programmer-defined command-line switches.


What does charred mean?

The full form of this is: char* argv[]; Where argv is a pointer to a null-terminated array of null-terminated strings. We use this type of argument to pass command line switches to the main function: int main (char * argv[], int argc); The names of these arguments, argv and argc, are conventional. The argc argument tells us how many elements are in the argv argument, such that argv[0] is the full-qualified name of the executable and argv[argc] is the null-terminator of the array. Any and all other elements (argv[n], such that 0&lt;n&lt;argc) represent programmer-defined command-line switches.


What is the Syntax of recursion in turbo c?

Nothing. A function may call itself just like any other function, eg: int main (int argc, char **argv) { if (argc&gt;0) { puts (argv[0]); main (argc-1, argv+1); } return 0; }


Can you give an example of array program?

int main (int argc, char *argv[]) { int i; for (i=0; i&lt;argc; ++i) printf ("%2d: %s\n", i, argv[i]); return 0; }


What is an example of array?

argv, which is the second parameter of function mainint main (int argc, char *argv[])


What does the C and V in argc and argv stands for?

count, values


What is earlier declaration for main?

pick one: int main (void); int main (int argc, char **argv); int main (int argc, char **argv, char **envp);


Sample do while loop in turbo c?

int main (int argc, char **argv) { int i=0; do printf ("%2d. %s\n", i, argv[i]); while (++i&lt;argc); return 0; }


What is the work of argc and argv in c program?

The argc and argv identifiers in a (standardly declared) main function allow access to the command line arguments. The standard declaration is... int main (int argc, char *argv[]) ...or... int main (int argc, char **argv) The number of arguments is stored in argc. Since the name of the program is, by convention, always implicitly the first argument, then argc is always at least 1, even if there are no arguments. Each argument, then, is stored in argc[i], where i ranges from 0 to argc-1. The name of the program is stored at argv[0], and further arguments are argv[1], argv[2], etc. Normal convention is that each white space separated word on the command line is an argument. The exception is in the case of a quoted argument, in which case the entire quoted string, minus the quotes, is a single argument. Is is an error to attempt to write to any argument. If parsing by side effect parsers, such as with strtok(), is to be done, a copy of the argument must be made.