定义:
int *p[size] //表示数组存的是指针,有size个指针数据
定义:
int (*p)[size] //数组指针,存储size个int类型的数据
指针函数
指针函数是一个函数,该函数返回的是一个指针;
函数指针是一个指针,该指针指向一个函数;
#include <stdio.h> int* getIntPoint(const int a) //指针函数,是一个函数 返回一个指针; { int *p = nullptr ; p = new int ; *p = a; return p ; } int main(int argc, char const *argv[]) { int *(*p)(int) = getIntPoint ; //函数指针,该指针指向一个函数; int* pInt = p(5); //使用函数指针; printf("%d\n",*pInt); delete pInt ; return 0; }
申明结构体数组: 结构体名 数组名【size】
结构指针变量说明的一般形式为:
struct 结构体名 *结构体指针变量名 struct student *p = &Boy; //假设事先定义了 struct student Boy;