C-pointer essay

Source: Internet
Author: User

1. A pointer is a variable that stores the memory address of a computer.

Int A; Define a variable

Int *p;//defines a P-pointer

p = &a;//and int *p = &a; equivalent

Depending on where you appear, the operator * can be used to declare either a pointer variable or a pointer value. When used to declare a variable, * means that a pointer is declared here. Other cases use * to indicate the value of the pointer.

& is an address operator that can reference a memory address. Use the & operator before the variable name to get the memory address of the variable.

2. An array is a contiguous memory space that can store specific objects and pointers to store a single memory address. You can assign the address of the array to the pointer, and the pointer to the address of the first element of the array.

Int Arr[3] = n/A;

int *p = arr;//and int *p = &arr[0]; equivalent;

3. As with arrays, pointers to structs store the memory addresses of the first element of a struct.

4. The pointer's pointer holds the memory address of the first pointer

If P1 stores the P2 memory address, then *P1 is returning the object that P1 saved.

&: Take address. *: Value.

C-pointer essay

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.