Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1482577
  • 博文数量: 181
  • 博客积分: 3308
  • 博客等级: 中校
  • 技术积分: 2227
  • 用 户 组: 普通用户
  • 注册时间: 2010-10-03 12:03
个人简介

我是zoro

文章分类

全部博文(181)

文章存档

2015年(1)

2013年(35)

2012年(39)

2011年(50)

2010年(56)

分类: LINUX

2013-04-02 16:20:59


转自:http://imeradio.blog.163.com/blog/static/15341940420101022101154896/

在X264的代码中发现了这样的用法:

uint16_t (*quant4_mf[4])[16];
为了测试这种用法,写了个小程序
#include
#include
#define INDEX1 4
#define INDEX2 5
#define INDEX3 6
typedef struct Test
{
int (*m1[4])[2];
int (*m2[4])[2];
}TEST;
void main()
{
int (*m[INDEX1])[INDEX3];
int i,j,k;
FILE *fp;
fp = fopen("tr.txt", "w");
for(i=0; i {
m[i] = malloc(INDEX2*INDEX3*sizeof(int));
}

for(i=0; i {
fprintf(fp, "m[%d]:0x%x\n", i, m[i]);
for(j=0; j {
fprintf(fp, "\tm[%d][%d]:0x%x\n", i, j, m[i][j]);
for(k=0; k fprintf(fp, "\t\tm[%d][%d][%d]:0x%x\n", i, j, k, &m[i][j][k]);
}
}

for(i=0; i {
free(m[i]);
}

fflush(fp);
fclose(fp);
printf("TEst size: %d\n", sizeof(TEST));
getchar();
}
运行后:
TEst size: 32
tr.txt文件的内容为:
m[0]:0x372e90
m[0][0]:0x372e90
m[0][0][0]:0x372e90
m[0][0][1]:0x372e94
m[0][0][2]:0x372e98
m[0][0][3]:0x372e9c
m[0][0][4]:0x372ea0
m[0][0][5]:0x372ea4
m[0][1]:0x372ea8
m[0][1][0]:0x372ea8
m[0][1][1]:0x372eac
m[0][1][2]:0x372eb0
m[0][1][3]:0x372eb4
m[0][1][4]:0x372eb8
m[0][1][5]:0x372ebc
m[0][2]:0x372ec0
m[0][2][0]:0x372ec0
m[0][2][1]:0x372ec4
m[0][2][2]:0x372ec8
m[0][2][3]:0x372ecc
m[0][2][4]:0x372ed0
m[0][2][5]:0x372ed4
m[0][3]:0x372ed8
m[0][3][0]:0x372ed8
m[0][3][1]:0x372edc
m[0][3][2]:0x372ee0
m[0][3][3]:0x372ee4
m[0][3][4]:0x372ee8
m[0][3][5]:0x372eec
m[0][4]:0x372ef0
m[0][4][0]:0x372ef0
m[0][4][1]:0x372ef4
m[0][4][2]:0x372ef8
m[0][4][3]:0x372efc
m[0][4][4]:0x372f00
m[0][4][5]:0x372f04
m[1]:0x372f48
m[1][0]:0x372f48
m[1][0][0]:0x372f48
m[1][0][1]:0x372f4c
m[1][0][2]:0x372f50
m[1][0][3]:0x372f54
m[1][0][4]:0x372f58
m[1][0][5]:0x372f5c
m[1][1]:0x372f60
m[1][1][0]:0x372f60
m[1][1][1]:0x372f64
m[1][1][2]:0x372f68
m[1][1][3]:0x372f6c
m[1][1][4]:0x372f70
m[1][1][5]:0x372f74
m[1][2]:0x372f78
m[1][2][0]:0x372f78
m[1][2][1]:0x372f7c
m[1][2][2]:0x372f80
m[1][2][3]:0x372f84
m[1][2][4]:0x372f88
m[1][2][5]:0x372f8c
m[1][3]:0x372f90
m[1][3][0]:0x372f90
m[1][3][1]:0x372f94
m[1][3][2]:0x372f98
m[1][3][3]:0x372f9c
m[1][3][4]:0x372fa0
m[1][3][5]:0x372fa4
m[1][4]:0x372fa8
m[1][4][0]:0x372fa8
m[1][4][1]:0x372fac
m[1][4][2]:0x372fb0
m[1][4][3]:0x372fb4
m[1][4][4]:0x372fb8
m[1][4][5]:0x372fbc
m[2]:0x370ff0
m[2][0]:0x370ff0
m[2][0][0]:0x370ff0
m[2][0][1]:0x370ff4
m[2][0][2]:0x370ff8
m[2][0][3]:0x370ffc
m[2][0][4]:0x371000
m[2][0][5]:0x371004
m[2][1]:0x371008
m[2][1][0]:0x371008
m[2][1][1]:0x37100c
m[2][1][2]:0x371010
m[2][1][3]:0x371014
m[2][1][4]:0x371018
m[2][1][5]:0x37101c
m[2][2]:0x371020
m[2][2][0]:0x371020
m[2][2][1]:0x371024
m[2][2][2]:0x371028
m[2][2][3]:0x37102c
m[2][2][4]:0x371030
m[2][2][5]:0x371034
m[2][3]:0x371038
m[2][3][0]:0x371038
m[2][3][1]:0x37103c
m[2][3][2]:0x371040
m[2][3][3]:0x371044
m[2][3][4]:0x371048
m[2][3][5]:0x37104c
m[2][4]:0x371050
m[2][4][0]:0x371050
m[2][4][1]:0x371054
m[2][4][2]:0x371058
m[2][4][3]:0x37105c
m[2][4][4]:0x371060
m[2][4][5]:0x371064
m[3]:0x3710a8
m[3][0]:0x3710a8
m[3][0][0]:0x3710a8
m[3][0][1]:0x3710ac
m[3][0][2]:0x3710b0
m[3][0][3]:0x3710b4
m[3][0][4]:0x3710b8
m[3][0][5]:0x3710bc
m[3][1]:0x3710c0
m[3][1][0]:0x3710c0
m[3][1][1]:0x3710c4
m[3][1][2]:0x3710c8
m[3][1][3]:0x3710cc
m[3][1][4]:0x3710d0
m[3][1][5]:0x3710d4
m[3][2]:0x3710d8
m[3][2][0]:0x3710d8
m[3][2][1]:0x3710dc
m[3][2][2]:0x3710e0
m[3][2][3]:0x3710e4
m[3][2][4]:0x3710e8
m[3][2][5]:0x3710ec
m[3][3]:0x3710f0
m[3][3][0]:0x3710f0
m[3][3][1]:0x3710f4
m[3][3][2]:0x3710f8
m[3][3][3]:0x3710fc
m[3][3][4]:0x371100
m[3][3][5]:0x371104
m[3][4]:0x371108
m[3][4][0]:0x371108
m[3][4][1]:0x37110c
m[3][4][2]:0x371110
m[3][4][3]:0x371114
m[3][4][4]:0x371118
m[3][4][5]:0x37111c
结论:(*m[])[]可以作为三维数组用。
阅读(1492) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~