CSAPP Chapter3 node2

#define N 8
typedef int fix_matrix[N][N];
fix_matrix A;				//declare A as a two-dimension array


when we create array of arrays,the declaration

int A[8][8]
is equivalent to the declaration:

typeof int row_t[8];<span style="white-space:pre">			</span>//regard int[8](32bytes) as a new type
row_t A[8];<span style="white-space:pre">				</span>//create a array of type "row_t"



<span style="white-space:pre">	</span>printf("size of A is %d\n",sizeof(A)); 				//8bytes 
	printf("size of A[0] is %d\n",sizeof(A[0]));			//32bytes
	printf("size of A[0][0] is %d\n",sizeof(A[0][0]));		//4bytes
	printf("size of int is %d\n",sizeof(int));			//4bytes
	printf("size of int* is %d\n",sizeof(int *));			//8bytes
A is a const pointer which stores the start addr of array row_t[8].

A[0] is a row_t, whose size is 32 bytes.

A[0][0]  is int whose size is 4 bytes

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值