The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+1 vote
73 views
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 .
asked in Programming by Active (2.4k points) | 73 views
which part you did not understand ?

You must have a good strategy while preparing for GATE exam. Plan you strategies ahead and work accordingly, then you won’t find cracking GATE exam that difficult. I have shared a blog which can help you in strategizing your study and gate coaching online. Hope you will find it helpful. Best of Luck

1 Answer

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
answered by Veteran (11.5k points)


Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

28,946 questions
36,792 answers
91,068 comments
34,689 users