指针数组与数组指针,结构体数组与结构体指针

匿名 (未验证) 提交于 2019-12-02 23:49:02

定义:

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;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!