第一:
p = (int *)sp
VS p = int *sp
VS p = int (*sp)
第二:
(struct node*) malloc(sizeof(struct node))
VS struct node* malloc(sizeof(struct node))
VS struct node (*malloc(sizeof(struct node)))
第三:
#define cEEP_ABC *((CHAR *)ps8c_PROM( EEP_TEST+0x2B ))
第1和第2个问题中的陈述有何不同?
对于第3个问题,*((CHAR *)ps8c_PROM( EEP_TEST+0x564 ))
^ ^
| |
| |
| |
---------------- What the purpose for these 2 pointer?
声明是否可以更改为此表单:*(CHAR *ps8c_PROM( EEP_TEST+0x2B )) or *(CHAR (*ps8c_PROM( EEP_TEST+0x2B )))
?
答案 0 :(得分:0)
<强>第一强>:
p = (int *)sp; //typecasting sp to int* and storing it in p
p = int *sp; //Declares sp as int* and its value is stored in p
p = int (*sp); //Compilation error
<强>第二强>:
(struct node*) malloc(sizeof(struct node)); //Allocates memory equal to size to struct node and returns a pointer to the start
Others: Compilation error.
<强>第三强>:
(CHAR *)ps8c_PROM( EEP_TEST+0x564 )
将函数的返回值强制转换为char *
,前导*
给出该地址指向的值。所以它返回char
。