Constant pointer, pointer constant, constant pointer constant

Source: Internet
Author: User

1#include <stdio.h>2 3 intMain ()4 {5     intA = -;6     intb = -;7 8     /*9 * Constant pointer, can not modify point to addressTen * The value in the storage space, but you can modify the value pointing to the address One      */ A     int Const*P1 = &A;  -     Const int*P2 = &a;//constant Pointer -  the     /*  - * Pointer constant, can not modify the address pointed to - * But you can modify the contents of the point in the address storage space -      */ +     int*ConstP3 = &b; -  +     /* A * Constant pointer constant, the address pointed to and the value in the storage space at * Can not be modified -      */ -     Const int*ConstP4 = &A; -     int Const*ConstP5 = &b;//constant Pointer Constants -  -  inP1 = &b;//constant pointer, you can modify the address pointed to -P2 = &b;//constant pointer, you can modify the address pointed to to      +*P3 =Ten;//pointer constants, you can modify the contents of the storage space -   //P3 = &a;//pointer constant, cannot modify the address pointed to the      *   //P4 = ten;//pointer constant, can not modify the point to address but can modify the point in the address storage space content $  //P5 = &a;//pointer constant, can not modify the point to address but can modify the point in the address storage space contentPanax Notoginseng  -printf"%d %d%d%d%d", *p1, *P2, *P3, *P4, *p5); the  +     return 0; A}

Constant pointer, pointer constant, constant pointer constant

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.