C Language Pointers

Source: Internet
Author: User

1. The pointer is the same type as int char float, called the pointer type, denoted by *

2, pointer variable, pointer variable is what type of pointer, depends on what type of variable it points to

Integer pointer int *

String char *

Floating-point Pointer float *

3, note: The pointer can only point to a block address, cannot point to a constant value

For example int *p = 10; This is wrong.

& means take address, &a

so int *p = &a;

4. The pointer variable is 8 bytes in memory (64-bit operating system)

5. The function of the * number

1. Define a pointer variable

2.* (pointer variable) = = Gets the value of the variable pointed to by the pointer

For example int a = 10;

int *p = &a;

*p = 10;

(*p) + + =a++ = 11;

* (p++) = * (Next memory space of P) = the value in the next training space of P is treated as an address, and the corresponding value of this address is obtained.

6. Constant pointer

const int *PA = &a;

*pa = 20; Cannot change the value of the variable pointed to

PA = &b; can change pointer pointing

7. Pointer constant

int *const PA = &a;

*pa = 20; You can change the value of the variable pointed to by the pointer

PA = &b; cannot change pointer pointing

8. Constant pointer to constant

const int *const PA = &a;

*pa = 20;

PA = &b;

C Language 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.