Test your skills
What are far pointers, near pointers, and huge pointers in the C programming language? What can they be used for? Thanks.
Near pointer is The pointer which cans points only 64 KB data segment or segment number 8 . That is near pointer cannot access beyond the data segment like graphics video memory, text video memory etc. Size of near pointer is 2 byte.
The far pointer is the pointer which can point or access whole the residence memory of RAMS i.e. which can access all 16 segments, Size of far pointer is 4 byte or 32 bit.
The pointer which can point or access whole the residence memory of RAM i.e. which can access all the 16 segments, Size of huge pointer is 4 byte or 32 bit.
Since you want to know all about the different types of pointers in C language, let’s define first the meaning of a pointer. A pointer is a variable where its content is the address of another variable. An example of this is the exact address of the memory location.
Like any other constant or variable, you need to declare a pointer first before you can actually use it to store variable address. The correct syntax in declaring a pointer is:
“type” is the base type of the pointer and it should be a valid C data type. “var-name” is the pointer variable’s name. Below are examples of valid pointer declaration:
A far pointer is the type of pointer that can access as a whole the entire memory segments of the memory, like for example all 16 segments of the memory as what is described in the image below.
Here is an example of a far pointer that will have an output of 4.
int far *ptr;
The near pointer is the type of pointer that can only point 64kb data segment. See the image below.
Here is an example of near pointer that will have an output of 2.
int near* ptr;
The huge pointer is the type of pointer that can point to the entire 16 segments of the memory. This is similar to the far pointer. See the image below.
Here is an example of huge pointer that will have 4 4 1 as the output.
char huge * far *p;
printf("%d %d %d",sizeof(p),sizeof(*p),sizeof(**p));
So, to sum it all, the three types of pointers are: