i have two questions right now in my mind :
question - 1 :
please have a look at this code :
here...when p is passed to function, the thing that actually takes place is :
a new variable recd is created and value of p is copied to recd (i mean a copy of p is created...consu ming another 2 bytes)...
now please check the following code :
does the same thing happen here?? i mean here too.. new pointer variable recd is created and value (an address) stored in pointer p is copied to recd???
and here too, does the same thing happens???
please throw some light on it... :)
question - 2:
in the above code, where the hell is 10 stored???
what exactly happen in above code??
my guess is : its stored in *p...
i mean **p has a garbage which is taken as *p...and *p has a garbage which is taken as the address of 10....is this right or a garbage?? :P :)
question - 1 :
please have a look at this code :
Code:
void function (int recd) { printf ("%d", recd); } void main() { int p=10; function(p); }
a new variable recd is created and value of p is copied to recd (i mean a copy of p is created...consu ming another 2 bytes)...
now please check the following code :
Code:
void function (int *recd) { printf ("%d", *recd); } void main() { int *p; *p=10; function(p); }
Code:
void function (int *recd) { printf ("%d", *recd); } void main() { int p=10; function(&p); }
please throw some light on it... :)
question - 2:
Code:
void main() { int **p; **p = 10; }
what exactly happen in above code??
my guess is : its stored in *p...
i mean **p has a garbage which is taken as *p...and *p has a garbage which is taken as the address of 10....is this right or a garbage?? :P :)
Comment