GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
60 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 (2k points)   | 60 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 Loyal (4.7k points)  


Top Users Sep 2017
  1. Habibkhan

    6960 Points

  2. Warrior

    2424 Points

  3. Arjun

    2358 Points

  4. rishu_darkshadow

    2136 Points

  5. A_i_$_h

    2004 Points

  6. nikunj

    1980 Points

  7. manu00x

    1750 Points

  8. makhdoom ghaya

    1750 Points

  9. Bikram

    1744 Points

  10. SiddharthMahapatra

    1718 Points


26,059 questions
33,665 answers
79,739 comments
31,078 users