Linux C Language notes pointer, linuxc language pointer

Source: Internet
Author: User

Linux C Language notes pointer, linuxc language pointer

1. the pointer is a variable, and the pointer has a variable feature: the system allocates memory space for the pointer; the pointer has its own address; the pointer can store a value, but this value is special-address

2. the pointer value is also called the memory region address pointed to by the pointer. The pointer value is the value stored by the pointer itself. This value is used by the compiler as an address rather than a general value. The memory area occupied by the pointer itself is 4 bytes in length.

3. indirect reference pointer. For a specified variable, the variable name is an indirect reference to the variable value. For any object pointer pointing to a variable or memory, the pointer is indirectly referenced to the object. If p is a pointer, the value of p is the address of the object. * p indicates that the indirect reference operator is applied to p, and * p indicates the value of the object pointed to by p.

4. constant pointer and pointer constant: the content of a constant pointer is immutable, but the address can be changed. That is, the pointer can point to another address, and the pointer constant is immutable, the content can be modified. Note the following two points: 1. If the pointer constant points to a self-owned pointer variable, you can modify * p in principle and pass it during compilation, but not during runtime, because it tries to modify the content of the constant area, the display is invalid. 2: When the pointer constant points to another pointer, when the Pointer Points to other content, the pointer constant still points to the original content.

5. function pointers and pointer functions:

(1) function pointer: refers to the pointer to this function, defined as "data type (* fun) (parameter list);", () priority is higher, so fun is enclosed in parentheses, such as "void (* fun) (int *, int *);".

(2) pointer function: the return value is a pointer function, which is defined as "" data type * fun (parameter list); "for example," char * fun (int *, int *); ", that is, the return value is char * type.

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.