C Programming - Command Line Arguments - Discussion

2. 

Which of the following statements are FALSE about the below code?

int main(int ac, char *av[])
{
}

[A]. ac contains count of arguments supplied at command-line
[B]. av[] contains addresses of arguments supplied at a command line
[C]. In place of ac and av, argc and argv should be used.
[D]. The variables ac and av are always local to main()

Answer: Option C

Explanation:

No answer description available for this question.

Madhu said: (Mar 4, 2011)  
Can you please explain how answer is C?

Sreejith said: (Aug 23, 2011)  
All options are true, no false statements. Option c is also right.

Nandu said: (Dec 27, 2011)  
Ya here all options are correct.opt 3 also right.bcoz actual syntax for command lines z
int main(int argc, char *argv[])

None said: (Feb 13, 2012)  
What's the problem with those words use in main as argument ?

Sush said: (Dec 15, 2012)  
ac and av are just identifiers and so are argc and argv. So there is no constraint that these identifiers "SHOULD BE" argc/argv only!

Akshay said: (Mar 7, 2014)  
Answer C is not correct for this question. According to Posix standard and other standards for declaring variable names, variable name can be any valid variable name. In this case we can use ac and av instead of argc and argv since these are only variable names for argument counter and argument vectors of command line argument.

Rohitah said: (Jan 4, 2016)  
Answer C is wrong because we can take any variable name at place of argc and argv. This is not compulsory to take variable name argc argv and remaining all options are correct.

Arunmane said: (Mar 4, 2016)  
All the options are correct. In option C we can do like that. I did this in GCC Compiler.

Pramod said: (Aug 9, 2017)  
Can anyone explain option B?

Ron said: (Feb 4, 2018)  
C should be reworded to "MUST be". It is true that it "should" be - various code style guidelines suggest that argc and argv should generally be used in main. Ac and av is misleading since it's not the standard way of doing it, and if I were correcting this code I would tell a person "hey you should change them to argc and argv, everyone uses those. ".

If answer remains C it should be reworded to "MUST" rather than "SHOULD".

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.