Discussion :: Command Line Arguments - Find Output of Program (Q.No.8)
|Hariom said: (Oct 21, 2010)|
|Can't understand logic, please help me to undestnd the logic behind it.
I can't understand the roll of dpuble pointer.
|Sugimalathi said: (Jan 11, 2011)|
|Explain this answer please.|
|Shanmugam said: (Jan 31, 2011)|
|argv = "sample";
argv = "friday";
argv = "thuesday";
argv = "sunday";
argv indicates argv.so ++argv increments to the next 1-D array.so it points argv.Then **argv is points 'f'.
|Manish said: (Mar 13, 2011)|
|I still could not get understood yet. Please further explain.|
|Lakshmi said: (Mar 31, 2011)|
|Its not clear.|
|Rookie said: (Jun 26, 2011)|
|As said by Shanmugam, argv indicates argv.++argv points to argv...now *argv is a pointer to second argument vector.
**argv contains the value "friday".But as we are printing "%c",
we get only the first character. i.e. "f".. thats why the ans.
|Bhimeswar said: (Jul 21, 2011)|
|Here in main brackets we write chaar *argv so the base address goes to*argvif we inrcrement second string address is *argv
**argv means string but in printf we wrote %c only so it displays first character f.
|Deepika said: (Feb 23, 2012)|
|Why **argv is used?|
|Alli said: (Apr 6, 2012)|
|Give complete meaning for **argv|
|Cherry said: (Jul 1, 2012)|
Meaning of **argv is  takes the first precedence so, it is the array of pointer to pointer and answer for above program is argv is "friday" with in this string(friday) initially pointer shows 'f' now increment it
Hope you understand.
|Akash Kumar said: (Jan 16, 2014)|
|Since in the printf the %c is written so the output come f if %s is given then at this case it will friday.|
|Abp said: (Feb 15, 2016)|
|Yes if there was %s in out then output would be friday.|
|Saurabh Dhakate said: (Apr 6, 2016)|
|But how would it take those arguments as there is no scanf statement inside of the code?|
|Rajesh Kumar said: (Jun 11, 2016)|
|Friends Shanmugam provides complete solution of this problem. Read pointer carefully, it'll help you.|
|J.Sangeetha said: (Aug 27, 2016)|
|I want a clear explanation for this question. Please provide me.|
|Achsah said: (Sep 18, 2017)|
|First of all, char* argv declaration is same as char **argv. this char **argv is the character array pointer.
In this program, we are incrementing the array, so it goes from argv to argv and we are printing only one char %c so it prints the first letter alone.
Post your comments here:
Email : (optional)
» Your comments will be displayed only after manual approval.