const char and static const char

Source: Internet
Author: User

The version withconst char *Would copy data from a read-only location to a variable on the stack.

The version withstatic const char *References the data in the Read-only location (no copy is performed).

inside the function. const char * Each time a function is called, it is necessary to allocate memory on the stack and then copy the data and release it before the function exits.

and static Const char *, will direct access to read only data, no need to allocate memory on the stack.

char * Const CP: Defines a pointer constant that points to a character, that is, a const pointer

Const char* P: Defines a pointer to a character constant

Char const* p: equals to const char* p


const char and static const char

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.