154k views
0 votes
What does argc tell us in a C programs parameters?

User Rottmann
by
8.4k points

1 Answer

2 votes

Final answer:

In C programming, the parameter argc indicates the number of command-line arguments passed, which includes the program name and the actual arguments meant to modify program execution.

Step-by-step explanation:

argc in a C program's parameters tells us the number of command-line arguments passed to the program. When you run a program from the terminal or command prompt, argc will be a count of how many arguments you've included. For example, if you execute a program like ./myprogram arg1 arg2, argc will be 3 (1 for the program name itself, and 1 for each argument).

The argv array holds the actual arguments, with argv[0] being the name of the program, and argv[1], argv[2], and so on being the successive command-line arguments. These parameters are typically used to customize the behavior of a program without changing the code, by providing inputs that affect its execution.

User Kiranramchandran
by
7.5k points