Discussion :: Command Line Arguments - Find Output of Program (Q.No.18)
|Balaji M said: (Dec 10, 2010)|
|I need explanation regarding your answer.|
|Pandi said: (Dec 17, 2010)|
|pls tell me about the detailed answer|
|Arvind said: (Feb 22, 2011)|
|The first parameter inside main() contains the number of command line arguments. so sizeofargv = 4.
The second parameter inside main() contains the command line arguments as an array of string. so
*argv = sunday
*argv = tuesday
*argv = friday
*argv = sample
|Mani said: (Jun 23, 2011)|
|Prudhvi said: (Jul 20, 2011)|
|Here sample is name of the program how can be it be an argument ?|
|Yogesh said: (Aug 27, 2011)|
|The first parameter inside main(....)determines the number of cmd line arguments i.e sizeofargv=4.
and second parameter stores the actual parameters in array
argv = sunday
argv = tuesday
argv = friday
argv = sample
while loop executed four times. It breaks when value of sizeofargv becomes -1.
in first execution: argv=sunday
in second execution: argv =tuesday
in third execution: argv=friday
in fourth execution argv=sample
now value of sizeofargv becomes -1 and loop breaks.
|Ferissa said: (Sep 12, 2011)|
|Hi pruthvi this is ferissa, I think there is no error when the program name matches with the argument.|
|Narmada said: (Nov 2, 2011)|
|Pruthvi in c for command line arguments the program name will be consider as first argument as argv. So sample will be stored in argv.|
|Prakash said: (Dec 10, 2011)|
Post your comments here:
Email : (optional)
» Your comments will be displayed only after manual approval.