Pointer is of five types::
1.Wild pointer:
A pointer which has not been initialized is known as wild pointer.
int *ptr;
printf("%d",*ptr);
//Output: Garbage Value
2.Dangling pointer:
If any pointer is pointing the memory address of any variable but after some variable has deleted from that memory location while pointer is still pointing such memory location. that pointer is known as dangling pointer .
int * call(){
int x=25;
++x;
return &x;
}
int *ptr;
ptr=call();
//Output: Garbage Value
3.Near pointer:
The pointer which can points only 64KB data segment and cannot access beyond the data segment .the Size of near pointer is 2 byte.
int near* ptr;
printf(“%d”,sizeof ptr);
//Output: 2
4.Far pointer:
The pointer which can point or access whole memory of RAM. Size of the pointer is 4 byte. We cannot change or modify the segment address of given far address by applying any arithmetic operation on it.
int far *ptr;
printf("%d",sizeof ptr);
//Output: 4
int far *near*ptr;
printf("%d %d",sizeof(ptr) ,sizeof(*ptr));
//Output: 4 2
Explanation: ptr is far pointer while *ptr is near pointer.
5.Huge pointer:
The pointer which can point or access whole the residence memory of RAM. Size of huge pointer is 4 byte.
Don’t use huge pointer:
Becouse ..This might be dangerous for your computer.
char huge * far *p;
printf("%d %d %d",sizeof(p),sizeof(*p),sizeof(**p));
//Output: 4 4 1
Explanation: p is huge pointer, *p is far pointer and **p is char type data variable.
double near *p,far *q;
printf("%d %d %d",sizeof(q),sizeof(p),sizeof(*p));
Output: 4 2 8
Explanation: q is far pointer, p is near pointer, *p is double data type constant.
0 comments:
Post a Comment