Knowledge of C pointer and C pointer

Source: Internet
Author: User

Knowledge of C pointer and C pointer

 

1. Summarize the knowledge of C pointer.

Level 1 pointer, one-dimensional array, array pointer

The array name of a one-dimensional array is a pointer, for example, int a [4] = {0}; a is equivalent to an int * p =.

Level 2 pointer, two-dimensional array, pointer Array

Two-dimensional array int aa [2] [3] = {0 }.

At this time, int ** pp = aa cannot be used, but it should be ** aa during access.

In fact, the first dimension of a two-dimensional array is int (* AB) [3]. It is a pointer array, not an array pointer.

In this case, int (AB) [3] is different from int *, so int (* AB) is used to accept two-dimensional arrays ). [3] = aa, the second-level pointer int ** pp = aa cannot be used. In this case, AB is the same as aa.

The pointer array is in the form of int * AB [3]. AB is first combined with [] to form a one-dimensional array,

The elements of this array are all int * pointers, so they are called pointer arrays. In this case, int ** p = AB can be used. Because the second-level pointer can only point to the position where int * is stored, and the array is an int * element, the array pointer is a second-level pointer, the two-dimensional array cannot be directly used as a second-level pointer.

It is a one-dimensional pointer array int (* AB) []. This pointer array is first interpreted as a pointer (* AB), then an array that stores int elements.

You can use this pointer AB to access the first element of * AB; (* AB) [1] The second element.

2. The concepts of function pointer array and pointer pointing to function pointer array are studied.

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.