C Pointer Summary

Source: Internet
Author: User

In c language learning, pointers, arrays, functions, etc. are well known to us, but when really encountered or really used, there is inevitably some confusion. Here's a look at pointers:

Pointer: Popular speaking is the address of the memory unit, is a constant. In other words, address.

Pointer variable: Allows a variable to hold a pointer in the C language, which is a pointer variable. is a variable. In other words, a variable that takes a value as an address. (But in peacetime we collectively refer to pointer variables as pointers, this to distinguish)

The type description of the pointer variable: the type specifier * variable name; two methods of initialization: int* p = &a or int* p;p = &a; ( It is a good habit to initialize the pointer when it is defined

Pointer variable operation: (1) Take address operator &: monocular operation, from right to left, function: Take variable address;

(2) Fetch content operator *: monocular operation, right-to-left, function: Used to denote a variable referred to by a pointer variable. (* is a type specifier in the type description)

Next, we will point out the difference between the array pointer, pointer array, function pointer, pointer function:

(1) Array pointer: The full name is the array pointer variable, pointer to the array variable becomes an array pointer variable, is a variable. Generic type: Type descriptor * pointer name

(2) Array of pointers: a set of ordered pointers. Generic type: type specifier * array name [array length]. This is the same as a two-dimensional array pointer variable but represents a different meaning.

(3) Function pointer: Full function pointer variable, a function always occupies a contiguous memory area, and the function name is the first address of the memory, assigning this address to a variable is a function pointer variable.

General form: type specifier (* pointer variable name) ();

(4) Pointer function: can be called pointer-type function, the return value is a pointer function. General form: type specifier * Function name (formal parameter list).

(three months into the park, still the same ignorance.) Last month determined to be a down-to-the-program ape, so began to supplement C knowledge. The above is a summary of their own, I hope you correct, at the same time I also summed up a bit).

C Pointer Summary

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.