C: Xiaoyi -- 2. Differences between several pointer concepts

Source: Internet
Author: User

After the Declaration and operation of pointers in the previous article, this article describes several common and important pointer concepts.

I. pointer constants and constant pointers

These two concepts also exist as follows. Like two connected words, the first word is a modifier, and the latter is a central word.

Constant pointer, which is a pointer to a constant. A constant Pointer Points to a constant to prevent the update of a constant from incorrect operations on the pointer. The content of the address pointed to by the pointer cannot be modified. A pointer constant is a constant first, and then a pointer. A pointer constant cannot modify the address to which the Pointer Points. Once Initialization is complete, the address to which the Pointer Points is fixed and cannot be moved.

2. pointer array and array pointer

These are two different concepts. Pointer array, that is, the elements of the array are pointer-formed; array pointer, that is, pointingArray pointer.

Iii. function pointers and pointer Functions

These are two confusing concepts, especially when they appear together.

A pointer function is a function with a pointer. It is essentially a function and returns a pointer of a certain type. It is defined as follows:

Return type identifier * return name (form parameter table) {function body}

In fact, every function has an entry address even if it does not contain a pointer of the return type, which is equivalent to a pointer pointing to the return value address. This pointer is equivalent to the function itself, that is, the entire function is equivalent to a "variable ".

A function pointer is a pointer variable pointing to a function. Therefore, it is a pointer variable first, except that the pointer variable points to a function. With the pointer variable pointing to the function, you can call the function just as the pointer variable references other types of variables.

4. Wild pointer

A wild pointer generally refers to a pointer that is not well controlled by the Code. When a pointer is defined in the program and the pointer is not directed to a specific address, the pointer will point to an address at will. Such a pointer is a wild pointer. If there is no important data in the memory space behind this address, it will not cause serious consequences. However, once useful data is stored in the address, the data may be accessed by wild pointers at any time, in this case, the data is damaged. Therefore, the existence of a wild pointer should be prohibited in the program.

Related Article

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.