C Programming - Command Line Arguments - Discussion
Discussion Forum : Command Line Arguments - Yes / No Questions (Q.No. 2)
2.
If the different command line arguments are supplied at different times would the output of the following program change?
#include<stdio.h>
int main(int argc, char **argv)
{
printf("%d\n", argv[argc]);
return 0;
}
Discussion:
25 comments Page 3 of 3.
Hema said:
7 years ago
Nice explanation Thanks @Sundar.
Matan said:
7 years ago
At the end of argv you have NULL terminator.
Let's say you have three arguments in the command line so argc=3.
then argv will be 4 element size and argv[3] will be '\0'. just like a string.
Let's say you have three arguments in the command line so argc=3.
then argv will be 4 element size and argv[3] will be '\0'. just like a string.
Manai said:
6 years ago
Nice explanations, Thanks All.
Mohit said:
5 years ago
Is "&" a pointer variable in c?
Suraj said:
5 years ago
Thank you @Sundar.
(1)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers