• Parth

What is the difference between near, far, and huge pointers in C and C++?


Near Pointer :- The pointer which can handle only 1 segment of of 1 mb data is called near pointer.Near Pointer doesn’t points to any other segments except data segments

Near Pointer doesn’t points to any other segments except data segments.

The size of near pointer is 2 bytes.


By default any type of pointer is near only.

When we are increments the near pointer value then it increase offset address only.

When we are applying the relational operators on near pointer then it compare offset address only. %p %x %u only specifier we can use.



Far Pointer:- Pointer variable which can handle any segment of 1 MB data is called far pointer.

When we are working with far pointer , it can handle any segment from the range ox0 to oxF, but at a time only one segment.

Size is 4 bytes, because it holds segment & offset address also.

When we are increments the near pointer value then it increase offset address only.

When we are applying the relational operators on far pointer then it compare segment address along with offset address .

We required to use %lp, %lu format specifiers for printing the far pointer address.

By using far keyword we can create far pointer.



Huge pointer :-  Pointer variable which can handle any segment of 1 MB data is called huge pointer.

When we are working with far pointer , it can handle any segment from the range ox0 to oxF, but at a time only one segment.

Size is 4 bytes, because it holds segment & offset address also.

When we are increments the near pointer value then it increase segment address along with offset address.

When we are comparing the huge pointers, it compares normalization value.

We required to use %lp, %lu format specifiers for printing the huge pointer address.

Normalization :- It is a process of converting 32 bit physical bit into 20 bit hexadecimal format.