The difference between near and far in C + +

Source: Internet
Author: User

The difference between near and far in C + +

the keywords near and far are affected by the target computer architecture. The current programming is not much used.

The NEAR keyword creates a target pointer to the low-end portion of the addressable memory. These pointers take up a single byte of memory, and they can point to a memory unit that is limited to a four-position, usually in the 0X0000~0X00FF range.

int near * ptr;

The FAR keyword creates a pointer that can point to any data in memory:

char FAR * ptr;

Near ( nearly ) pointer: offset Address in the four-bit segment

Far ( farther ) pointer: The address of the four-bit segment + the offset address in the

Huge ( giant ) pointer: a unique memory address normalized by the

The storage properties of the C language are determined by six compilation modes ( see the option->compiler->model option in the TC Integrated Environment menu ), and the default compilation mode is Small, in this compilation mode, the pointer's default property is near.

Add: The near pointer is a 16-bit pointer, relying on a segment address register, the pointer variable is the amount of displacement, using the segment address register + pointer addressing, so there is a limit of 64K.

         far  pointer is 32 bit pointer, There are not only 16 bit displacement, and 1616ffff

so, with the introduction of the huge pointer, thehuge pointer, like far , differs only by using a standardized method, so that all addresses have a unique representation, thus avoiding the problem of the far pointer.

The null pointer specifies a pointer state, if there is no null pointer, as the number is not 0.

The difference between near and far in C + +

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.