C language and pointer Learning

Source: Internet
Author: User

C language and pointer Learning

Encourage yourself to learn and use it!

--> Variables are not necessarily stored in the memory in the declared order.

--> & Operator: Get the variable address (pointer to the variable)
* Operators can obtain address variables.

Int j = 10;
Int * p = & j; // pointer p points to jint k = * j; // gets the variable pointed to by pointer p

--> Statement

Int * p;
Int * p; // equivalent
Int * p, p1; // two pointer variables cannot be declared. The second variable is int type.

--> Add N to the pointer, and forward the pointer to "the Data Type length pointed to by the current pointer xN"
--> Array subscript starts from 0

Int array [10];
Array [0]-> array [9] // 10 elements

--> Array and pointer

Int array [];
Int * p;

P = array [0];
P = array; // point the pointer p to the address of the starting element of the array.

* (P + I)
P [I]
/* Array name [array element]
Array name-> address of the starting element of the array, which can be understood as a pointer */
Array [2];
* (Array + 2); // they are equivalent

 

 

 

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.