我正在编写一个函数来显示调用者传递的指针值。因为我不想弄乱原来的**arr1,所以我给它分配了一个**P,然后我打印它并计算它。但随后左侧,即 arr1 变为零。
代码:
void merge(int **arr1, int **arr2, int **arr3)
{
int **p1= arr1;
int **p2= arr2;
int **p3= arr3;
int count;
printf("%d\n", **arr1); //this shows the correct value of first element of arr1
while(**p1)
{
printf("%d\n", **p1);
(*p1)++;
count++;
}
while(**p2)
{
printf("%d\n", **p2);
(*p2)++;
count++;
}
printf("%d\n", **arr1); // this become zero, why??i didn't touch it in my code didn't i?
}