数组指针,指针数组

#include <stdio.h>
#include <stdint.h>

#define BAP_FCT_ID_MAX 64

typedef struct
{
	uint16_t len;
	void *buffer;
}bap_cache_buffer_t;

bap_cache_buffer_t cache_info_table1[BAP_FCT_ID_MAX] = 
{
    {0,(void *)1},
    {0,(void *)2},
    {6,(void *)3},
};

bap_cache_buffer_t cache_info_table2[BAP_FCT_ID_MAX] =
{
    {0,(void *)4},
    {0,(void *)5},
    {6,(void *)6},
};

bap_cache_buffer_t cache_info_table3[BAP_FCT_ID_MAX] = 
{
    {0,(void *)7},
    {0,(void *)8},
    {6,(void *)9},
};



bap_cache_buffer_t * lcu_cache_info_table[2] =
{
    cache_info_table1,
    cache_info_table3,
};

typedef bap_cache_buffer_t *lcu_cache_info_table_t[2];

lcu_cache_info_table_t lcu_cache_info_table1 =
{
	cache_info_table1,
    cache_info_table3,
};

typedef bap_cache_buffer_t (*lcu_cache_info_table1_t)[64];
lcu_cache_info_table1_t p1[2] = 
{
(lcu_cache_info_table1_t)cache_info_table1,
(lcu_cache_info_table1_t)cache_info_table3
};

int main()
{
   /* 我的第一个 C 程序 */
   printf("Hello, World! \n");
 
   printf("cache_info_table_gap:%x\n", cache_info_table2);
   printf("%x\n", lcu_cache_info_table[1][1].buffer);
   printf("size:%d\n", sizeof(lcu_cache_info_table_t));
   printf("%x\n", lcu_cache_info_table1[0][1].buffer);
   printf("size:%d\n", sizeof(lcu_cache_info_table1_t));
   printf("size:%d\n", sizeof(p1));
   printf("a[0]:%x a[1]:%x, cache_info_table1:%x, cache_info_table3:%x\n"
		 ,p1[0], p1[1], cache_info_table1, cache_info_table3);
   printf("%x\n", p1[0][0]); //指向 bap_cache_buffer_t buf[BAP_FCT_ID_MAX]的数组首地址
   printf("%x\n", p1[0][1]);
   printf("%d\n", p1[0][0][0].buffer);
   printf("%x\n", p1[1][0]);
   printf("%x\n", p1[1][1]);
   printf("%d\n", p1[1][0][0].buffer);

   return 0;
}

运行结果:

Hello, World! 
cache_info_table_gap:404460
8
size:16
2
size:8
size:16
a[0]:404060 a[1]:404860, cache_info_table1:404060, cache_info_table3:404860
404060
404460
1
404860
404c60
7

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值