Detailed Explanation of "C Language Pointer Array" Review of Computer Science Upgraded Edition (First Draft)

C language pointer array (each element of the array is a pointer) detailed explanation

If all elements in an array are "saved as pointers", then we call it a " pointer array ".

The definition form of pointer array is generally as follows:

  dataType *arrayName[length];  

The precedence of [ ] is higher than * , and the definition form should be understood as:

    dataType *(arrayName[length]);

The inside of the brackets indicates that arrayName is an array containing length elements, and the outside of the brackets indicates that the type of each element is dataType *.

// Except for the data type of each element, pointer arrays and ordinary arrays are the same in other respects, the following is a simple example:

#include<stdio.h>

int main()

{

    int a = 16,b = 932, c = 100;

    //定义一个指针数组

    int *kangkang[3] = {&a,&b,&c}; //也可以不指定长度&#x

Supongo que te gusta

Origin blog.csdn.net/weixin_51563198/article/details/122785017
Recomendado
Clasificación