C Programming - Pointers - Discussion

Discussion Forum : Pointers - Point Out Correct Statements (Q.No. 4)
4.
In the following program add a statement in the function fun() such that address of a gets stored in j?
#include<stdio.h>
int main()
{
    int *j;
    void fun(int**);
    fun(&j);
    return 0;
}
void fun(int **k)
{
    int a=10;
    /* Add a statement here */
}
**k=a;
k=&a;
*k=&a
&k=*a
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
19 comments Page 1 of 2.

Chinnasamy said:   1 decade ago
any one explain this....

Deepti said:   1 decade ago
Its normal pointer assignment, whn fun is called its received as k, so whatever operation performed on k will be returned at j in main.

Prabhu said:   1 decade ago
By passing &j as argument,k has the address of j. *k is the value stored at j.so assignment statement *k=&a, stores address of a as value of j.

PAVAN said:   1 decade ago
AFTER DUNC CALL,
&J=**K;
J=*K;
IN FUNC FUN,
*K=&A;
SO,
J=&A;
SO ADDRESS OF A IS IN J

Heena said:   1 decade ago
Thanks pavan.

Meghali said:   1 decade ago
&J=**K
So, j=*K

We are assigning address of a to j.
So , J=&a
i.e *k=&a

Ted said:   1 decade ago
But there is no semicolon after the statement in the answer?

Shruti said:   9 years ago
What is the difference between **k & *k?

Ajay said:   9 years ago
**k will store value, whereas *k will store address.

Because int **k is pointer to pointer to the integer. When we apply once * on k we will get an address and on applying * second time on k we get value at (*k) address.
(1)

Hosam said:   8 years ago
Why not the option A?


Post your comments here:

Your comments will be displayed after verification.