Pointers in C Language & and *

Source: Internet
Author: User

1. pointer:

The pointer is the address. The pointer implements indirect access to the variable. The pointer of the variable is the address of the variable. The variable storing the variable address is the pointer variable;

& -- Get the address operator; get the address of the variable;

* -- Pointer operator (or "indirect access" operator); obtains the content of pointer variable (Address;

Int I = 3;

Int * P; -- Define the pointer Variable P

P = & I; -- equivalent to * P = 3;

2. pointers and arrays:

The array name is the starting address of the array, that is, the pointer (Note: However, the array name represents a fixed address or can be called a pointer constant and cannot be assigned a value, for example, operations such as a ++ are meaningless. Of course, after passing in a function as a real parameter, it can be completely used as a pointer variable in the parameter );

Int A [10];

Int * P;

P = & A [0];

P =;

* P = 1; equivalent to a [0] = 1;

P + I = a + I = & A [I];

* (P + I) = * (a + I) = A [I];

P [I] = * (a + I)

The form of the function participates in the real parameter:

When defining a function, the variable name in the ARC behind the function name is the form parameter. When calling a function in the main function, the parameter in the ARC behind the function name is called the real parameter. Only when a function is called, the memory unit is allocated only when the parameter is called. After the call, the memory unit of the parameter is released. The data transmission of the parameter variable to the parameter variable is value transfer, that is, one-way transmission. Only the real parameter is passed to the parameter, the parameter cannot be returned to the real parameter;

 

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.