416 views
1 votes
1 votes
In the following program add a statement in the function fun() such that address of a gets stored in j;

main()

{

int *j;

void fun(int **);

fun(&j);

}
void fun(int **K)

{

int a=10;

/*add statement here*/

}

answer  is *k=&a;

can anyone explain this .

1 Answer

0 votes
0 votes
func(&j)

func(int **k)

by this the address of j is passed to k

K=200, j is at address 200

now *k=&a => address of a is passed to *k i.e the place where k is pointing

k is pointing to j as it has the adress of j

thereby stores value of a in j

Related questions

0 votes
0 votes
1 answer
1
ermp888 asked Jun 30, 2018
641 views
6. Would the following program compile?main( ) { int a = 10, *j; void *k; j = k = &a; j++ ; k++; printf ("\n %u %u", j, k ) ; }Please explain above program with some exam...
1 votes
1 votes
1 answer
2
ermp888 asked Jun 30, 2018
808 views
(5) Would the following program give a compilation error or warning?main() { float i = 10, *j; void *k; k=&i; j= k; printf("\n%f", *j); }
1 votes
1 votes
2 answers
3
ermp888 asked Jul 1, 2018
500 views
13. What does the error "Null Pointer Assignment" mean and what causes this error?
0 votes
0 votes
2 answers
4
ermp888 asked Jun 27, 2018
1,622 views
Can you write another expression which does the same job as ++*ptr ?