Fun with pointer !, Funwithpointer

Source: Internet
Author: User

Fun with pointer !, Funwithpointer
Int x = 1; // the address of x is 50.

Statement P * P X
Int x = 1; const int * p = & x; 50: int y = 2; p = & y. Both p and * p are changed. 1 cannot be modified It can be changed. X = 2. * p = 2 at this time, but p remains unchanged.
Const int x = 1; const int * p = & x; 50 unchangeable 1 cannot be modified Unchangeable
Const int x = 1; int * p = & x; An error occurs only when a constant Pointer Points to a constant.    
Int x = 1; int * const p = & x; 50 unchangeable * P = 3; then x = 3. But p remains unchanged. It can be changed. * P changes, but p remains unchanged.
Int x = 1; const int * const p = & x; 50 unchangeable Unchangeable
It can be changed. X = 2. At this time, * p changes, but p remains unchanged.

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.