[C Language] Data Structure-preparation knowledge pointer and preparation pointer

Source: Internet
Author: User

[C Language] Data Structure-preparation knowledge pointer and preparation pointer

All greatness comes from a brave start

Data structure preparation

Pointer

1. pointer: it is the soul of C language, pointer = address

Address: Number of the memory unit

Pointer variable: the variable that stores the memory unit address

 

Int * p; // p is a pointer variable. int * indicates that the p variable can only store the address of the int type variable and cannot store other types.

Int I = 10;

P = & I

The two operations are detailed:

1) p stores the I address, so we say p points

2) p and I are two completely different variables. modifying any one of them will not affect the other.

3) p points to I, * p is the I variable itself. More vividly, all the places where * p appears can be changed to I

2. No matter how many bytes the pointing address occupies, all pointer variables only occupy 4 bytes, and the first byte address represents the address of the entire variable.

Pointers and functions

The variable in the function is a local variable. If the parameter is a pointer, you can modify the external variable.

Pointer and array

Int a [5] = {1, 2, 3, 4, 5}

A is a pointer that is always bright and stores the address of the first element of the one-dimensional array. Its value cannot be changed. The name of the one-dimensional array points to the first element of the array.

A [I] <=> * (a + I)

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.