Const qualifier, const limitation

Source: Internet
Author: User

Const qualifier, const limitation

 

 

1 int main () 2 {3 const int a; 4 int const B; 5 const char * c; // modify the memory variable c pointing to a pointer with a constant integer of 0 (the memory data pointed to cannot be changed, but the data itself can be changed) 6 char * const d; char buf [100]; // The constant pointer variable of d cannot be modified, but the memory data pointed to can be changed to 7 const char * const e; // The e pointer variable cannot be modified, and the memory data to be pointed to cannot be modified 8 9 // conclusion: the variable modified by const in C language is false 10 // const int num = 100; 11 // int * p = & num; 12 // * p = 50; 13 // printf ("% d \ n", num); 14 15 return 0; 16}

 

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.