memory model
near pointer
far pointer
Physical address calculation
huge pointer
How will we read complex pointer ?
(1) What is pointer ?
Ans:Pointer is variable which contain address of another variable.
e.g
1.
int i=3;meaning:-
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2t-GYcFUuOMmZKkDYmJMRYnKHS8pcFIPPkL9NGC6ta673aBz-6Pc5kPQhgqknpoXXq689QZSungkG8RQz9aHXDqz5laBKvxs8HHZy2_4D47NlLIecHijKZ9O0hspnTrcijd7CAPQgnEM/s400/a1.bmp)
6024 any arbitrary address.
2.
int i=3;
int *j;
j=&i;meaning:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgI1BACFvrCOEqGKmCyo4nwb4mVKcmqKNdmpgOi68Qe4pZDlH2b45EKBcQgO1Uqx4x3ovbLb-ZCqdRwJJ8iei04RmZUZCrHKD5nhtlhZmNuAZlEcZLZSjejeeOL1ngGY8RyjuSTgVuF90s/s400/a2.bmp)
3.
int i=3;
int *j;
int **k;
j=&i; //line 1
k=&j; //line 2
Meaning:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiD0ZWm6Uwb5YGp5-0cBIAa4gnpFvgLMeUHrxHMz_bTFs6efb2bLv7fq10BpwHgxpdW5q4mVXrthXLokfK5iqjIA8vc0stVphgdnuMPYmyXVu8tXX9suc0gCU6Wz51uFhBoUlh4g4BOur0/s400/a3.bmp)
Here both i and j are pointer where j contain 6024 which is address of variable I while j contain 8085 which is address of another variable which contain address of variable i.
Now
printf(“%d”, **k);
printf(“%d”,*j);
printf(“%d”,i);
Above all printf will give same output : 3
Explanation:* and & are canceled to each other i.e *&a=a
So **k
= **(&j) //from line 1
= *(*&j)
= *j //* and & are canceled to each other.
= *(&i) //from line 2
= *&i
= i
Thus **k = i ,hence **k is giving output 3
Same way *j = i
(2) What will output:void main()
{
int i=3;
int *j;
int **k;
j=&i;
k=&j;
printf(“%u %u %u”,i,j,k);
}Ans:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXNOUdar7GAQQpCkoIDGPF2am46Fu1LFyjB6AryJfL9OU_VBRySTqtXIiijYLvOCPSDHBLUlFJD2h0b58WNwfPtCsnQZhAfqtLkAE1WioNiUnkp6ld2GY8_I6NePPhE9DL7qoNEJul5qc/s400/a4.bmp)
Here 6024 ,8085,9091 is any arbitrary address,it may be different.
Since content of i is 3,so first output will 3
Content of j is 6024 ,so second output will 6024
Content of k is 8085 ,so third output will 9091
Output: 3 6024 8085
Note:-Address is always a whole number ,which can not be negative so we generally is %u instead of %d
VISIT HERE
What is pointer ?
memory model
near pointer
far pointer
Physical address calculation
huge pointer
How will we read complex pointer ?
No comments:
Post a Comment