c语言指向数组的指针之差,C语言指向数组的指针及容易混淆的概念.docx

C语言:指向数组的指针及容易混淆的概念

When learning C language, the pointer part did not learn very solid

Several unusual pointers:

Int (* P) [4] pointer to an array, pointing to an array like int a[4]

Int (* P) points to the function, which returns the int value

The int * P pointer to the pointer points to a pointer to the int variable

=============================== contrast

Int (* P) [4]

Int * P [4], where the latter is an array of pointers containing

4 int * type elements

Int (* P)()

Int * P (), where the latter is a function that returns the data of the int * type

Int (* P) [4]

Int * * P this issue needs to be discussed in detail We know that array index operations, such as a[3], are actually * (a+3), but * (a+3)

Such an operation does not simply take the address (constant or variable) plus 3 to fetch the value of the memory cell,

It's a+ 3*sizeof??? Then the memory unit value)? It can be called sizeof???"Step"〃?

Thus, each pointer variable must have a basic data type when it is declared, for example:

Declare basic step

Int * P int int

Int * * P int * pointer

Int (*p) [4] int a[4] 4 * int

The int (*p) () func compiler determines that

Int * PT[4], this is an array containing 4 int * P

Int * FN (), which is the function, returns 1 int * P

In fact, the int * P pointer level is equivalent to int * PT[4],

but the PT here is

Pointer constants, while P is pointer variables, can be p二PT, that is, the first address of the PT[4] array is assigned to pointer P?

P is used to store the address of pointer variables in memory and can be used to index this set of int variables, so say

It is the pointer to the pointer, and the first step is the length of the "pointer" type?

〃P[X][Y]" means..:

First read the value of the pointer variable from the P + X* sizeof ("pointer") p[X],

Then read the value of the int type variable from the p[X] + Y* sizeof (int) p[X][Y]?

In contrast, int (* Pa) [4] is called the pointer to an array, and here it is

A pointer to a one-dimensional array, assuming the assig

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值