C Programming - Command Line Arguments - Discussion

Discussion Forum : Command Line Arguments - General Questions (Q.No. 2)
2.
According to ANSI specifications which is the correct way of declaring main when it receives command-line arguments?
int main(int argc, char *argv[])
int main(argc, argv)
int argc; char *argv;
int main()
{
    int argc; char *argv;
}
None of above
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
8 comments Page 1 of 1.

DoSelect said:   9 years ago
American National Standards Institute: ANSI.

It's international standard.

Vimal said:   9 years ago
What is meant by ANSI?

Chandan Gupta said:   1 decade ago
No doubt Option (A) is right. In respect to command line Argument in c main() function takes two arguments First argument is argc which stands for argument count -it count the no of arguments which are given at the time of execution and argv is an array which stores the argument entered at command line.

Samadhan Adate said:   1 decade ago
Option A is correct bcz when you pass the arguments to any function you must have to specify the argument type(int,flot,char and so on)to hold the value of that type which is passed from the command line..first argument-to count number of arguments.second pointer array argument to hold actual passed values in array.

In option B that is not right definition of function where argument type is missing..

In option C there is no any arguments passed to main(),main() has two local variables..

Option D is wrong bcz option A is correct Answer.

Prashant said:   1 decade ago
Option A is correct .

int argc specifies number of arguments
and the char *argv[] is a pointer array which holds the adress values of all the command line arguments(inputs).

Sam said:   1 decade ago
Nice explanation.

Karthik said:   1 decade ago
In unix A option style is used
in turbo-c B option style is used
but they were same
argc is used for count;//argument count
argv is used for storage of variable type;//argument variable

Sagarborse said:   1 decade ago
Option A is correct
option B is Dennis Ritchie style/pattern of declaring function
option C have local variables instead of command-line arguments
option D no issues / no comment

Post your comments here:

Your comments will be displayed after verification.