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?
Discussion:
8 comments Page 1 of 1.
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
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
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
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
Sam said:
1 decade ago
Nice explanation.
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).
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).
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.
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.
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.
Vimal said:
9 years ago
What is meant by ANSI?
DoSelect said:
9 years ago
American National Standards Institute: ANSI.
It's international standard.
It's international standard.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers