4.8.2 练习定义几种指针及数组
Posted zhuluojigongyuan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了4.8.2 练习定义几种指针及数组相关的知识,希望对你有一定的参考价值。
#include <stdio.h> int main(void) { //已知几个数组的定义及其初始化 char str1[] = "str1"; char str2[] = "str2"; char str3[] = "str3"; char *a[] = {str1,str2,str3}; char *b[] = {"aaa","bbbb","ccccc","dddddd"}; char *c[] = {"aaa","bbbb","ccccc","dddddd"}; char *d[] = {"aaa","bbbb","ccccc","dddddd"}; //1.定义一个指向数组a的指针 int** pa = a; //2.1定义一个一维数组arr1,存储abcd四个数组的地址作为成员 char** arr1[4] = {a,b,c,d}; //2.2定义一个指向数组arr1的指针 char*** p1 = arr1; //3.1定义一个2X2的二维数组arr2,存储ab cd 四个数组的地址作为成员。 char** arr2[2][2] ={a,b,c,d}; //3.3定义一个指向数组arr2的指针 char** (*p2)[2] = arr2; //已知几个数组的定义及其初始化 char *e[][2] = {"aaa","bbbb","ccccc","dddddd"}; char *f[][2] = {"aaa","bbbb","ccccc","dddddd"}; char *g[][2] = {"aaa","bbbb","ccccc","dddddd"}; char *h[][2] = {"aaa","bbbb","ccccc","dddddd"}; //1.定义一个指向数组e的指针 char*(*pe)[2] = e; //2.1定义一个一维数组arr3,存储abcd四个数组的地址作为成员。 char*(*arr3[4])[2] = {e,f,g,h}; //2.2定义一个指向数组arr3的指针 char*(**p3)[2] = arr3; //3.1定义一个2X2的二维数组arr4,存储ab cd 四个数组的地址作为成员。 char*(*arr4[2][2])[2] = {e,f,g,h}; return 0; }
以上是关于4.8.2 练习定义几种指针及数组的主要内容,如果未能解决你的问题,请参考以下文章