C Programming - Command Line Arguments - Discussion

3. 

The first argument to be supplied at command-line must always be count of total arguments.

[A]. True
[B]. False

Answer: Option B

Explanation:

No answer description available for this question.

Shanmugam said: (Jan 31, 2011)  
The first argument is name of the program.

Tej said: (Jun 4, 2011)  
Can any explain any one please ?

Sukanya said: (Aug 9, 2011)  
Command line argument is the information followed by program's name on the command line of operating system.

Two special built in functions are present which specify the number of arguments on command line and pointer to an array of character pointers, those are argc and argv respectively.

Hence 1st argument is always program name.

Pank said: (Sep 28, 2011)  
@Sukanya please specify the prototype.

Jailani said: (Oct 15, 2011)  
If the program name is hello then:

int main(int argc,char *argv){
----------------
----------------
----------------
statements;
return o;
}

The output id:
cd>exc hello.c jailani sukanya tej
the value of argc is :3
and argv[0] is hello
argv[1] is jailani
and so on.

Rupinder said: (Dec 8, 2011)  
Answer is TRUE. Program name itself is an argument and always be the count of total arguments.

Pravin Agrawal said: (Aug 18, 2012)  
Answer is TRUE. Program name itself is an argument and always be the count of total arguments.I have tried it..

Shaan said: (Jul 2, 2013)  
Answer is TRUE. The first argument to be supplied at command-line must always be count of total arguments.

Seema said: (Sep 29, 2013)  
1st argument is always program name.

Swetha Madhuri said: (Oct 10, 2013)  
Hey guys the answer is false.

Because the question asked is first argument in command line not to main().

Hope you understand. :).

Rohan said: (Jul 22, 2015)  
@Swetha yeah correctly said me too was mistaken by the language used.

The question asked is "First argument to be supplied at command-line". They are asking If we need supply any such argument. So it's clearly false.

Sneha said: (Jun 29, 2016)  
The argc parameter is the count of total command line arguments passed to the executable on execution (including the name of the executable as the first argument).

So the answer is true.

Aman said: (Jul 22, 2016)  
No, the correct answer is false.

D.Mehul said: (Aug 29, 2016)  
The argument supplied in command line not main();.

The, the answer is false.

Soundar said: (Nov 26, 2016)  
Ans: FALSE, read the question again carefully (must always be count of total arguments) it says we should give the count ie the total number of argument we are going to use. Argc stores only the number of argument given during the run time.

Anomii said: (Aug 31, 2018)  
Answer is true as its the count.

Tripathi said: (Aug 31, 2018)  
Ans: argc (ARGument Count) is int and stores number of command-line arguments passed by the user including the name of the program. So if we pass a value to a program, value of argc would be 2 (one for argument and one for program name).

The value of argc should be non negative.

Argv (ARGument Vector) is array of character pointers listing all the arguments.

If argc is greater than zero, the array elements from argv[0] to argv[argc-1] will contain pointers to strings.

Argv[0] is the name of the program, After that till argv[argc-1] every element is command -line arguments.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.