#include<stdio.h>
int main()
{
int *previous, *current ;
int a[5] = {1,2,3,4,5};
current =(int *) a ;
previous = current ;
current = *( (int**) current ) ; //my question is on this line
printf ("\nprevious is 0x%x and current is 0x%x \n ", previous , current ) ;
printf ("\nprev+1 0x%x , prev+4 0x%x \n", previous+1 , previous+4 ) ;
return 0;
}
输出是:
bash-3.00$ ./a.out
previous is 0xffffd0f8 and current is 0x1
prev+1 0xffffd0fc , prev+4 0xffffd108
我的问题是:“当前”以前指向数组的开头,然后再被引用和取消引用。下面的语句如何改变“current”的值?
current = *( (int**) current ) ;
此外,如果我打印 *previous 它将打印 1 而 *current 将核心转储。这种行为的原因是什么?