C Programming - Command Line Arguments - Discussion
Discussion Forum : Command Line Arguments - True / False Questions (Q.No. 3)
3.
The first argument to be supplied at command-line must always be count of total arguments.
Discussion:
18 comments Page 1 of 2.
Shanmugam said:
1 decade ago
The first argument is name of the program.
Tej said:
1 decade ago
Can any explain any one please ?
Sukanya said:
1 decade ago
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.
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:
1 decade ago
@Sukanya please specify the prototype.
Jailani said:
1 decade ago
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.
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:
1 decade ago
Answer is TRUE. Program name itself is an argument and always be the count of total arguments.
Pravin Agrawal said:
1 decade ago
Answer is TRUE. Program name itself is an argument and always be the count of total arguments.I have tried it..
SHAAN said:
1 decade ago
Answer is TRUE. The first argument to be supplied at command-line must always be count of total arguments.
Seema said:
1 decade ago
1st argument is always program name.
Swetha Madhuri said:
1 decade ago
Hey guys the answer is false.
Because the question asked is first argument in command line not to main().
Hope you understand. :).
Because the question asked is first argument in command line not to main().
Hope you understand. :).
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers