C Programming - Command Line Arguments - Discussion

Discussion Forum : Command Line Arguments - Find Output of Program (Q.No. 21)
21.
What will be the output of the program (myprog.c) given below if it is executed from the command line?
cmd> myprog one two three
/* myprog.c */
#include<stdio.h>
#include<stdlib.h>

int main(int argc, char **argv)
{
    int i;
    for(i=1; i<=3; i++)
        printf("%u\n", &argv[i]);
    return 0;
}

If the first value printed by the above program is 65517, what will be the rest of output?

65525 65531
65519 65521
65517 65517
65521 65525
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
14 comments Page 2 of 2.

San said:   10 years ago
Your question is not correct.

You should define the platform property in the question.

Tim said:   1 decade ago
And on a 64-bit machine.... As the others said, this is architecture dependent.

Pinky said:   1 decade ago
Yes it should print 2nd 3rd and 4th argument address. Right?

Indal said:   1 decade ago
Please write the answer in easy way. Please help me!.


Post your comments here:

Your comments will be displayed after verification.