Pointer constants and constant pointers

Source: Internet
Author: User

These two concepts are often not clear, and today a good summary of it.
First, the pointer constant
The pointer constant is the first because it is related to the array we use most often.
Declaration of Pointer Constants

intconst p;

The pointer declaration operator is preceded by the constant qualifier const, which is called the pointer constant. Suddenly found a little regularity ^_^.
The const qualifier is decorated with pointers. The array name is a pointer constant. And what is the difference between an array name and a pointer? It is possible to modify the pointed memory by referencing the array name, but it cannot be assigned itself and cannot be used for + +,-operation.

Second, constant pointer
Declaration of a constant pointer

constint * p1;intconst * p2;

Constant Qualifier Const is called a constant pointer in front of the pointer declaration operator *.
The const modifier is the memory address that the pointer points to. The constant pointer and the pointer constant above are the opposite of the assignment behavior. itself can be assigned, support + +,-operation, but not by reference to the pointer to modify the point of memory.

Summary: Remember that the "array name is the pointer constant", this egg-ache problem even solved.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Pointer constants and constant pointers

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.