什么"输入**变量"意思?

时间:2016-05-18 16:42:44

标签: c

有人可以向我解释Cat之后的**是什么吗?如果它是指向指针的指针,那么不应该有空格吗?

    Cat fetch_and_kill_oldest(Cat** cat_array, int length){
    //This function tries to find the oldest cat, take away one life,
        Cat temp = cat_array[0];
        for(int i = 1; i < length; i++){
            if (cat_array[i].age > temp.age){
                temp = cat_array[i];
            }
        }
        temp.lives -= 1;
        return temp;
        //stop here
    }

1 个答案:

答案 0 :(得分:4)

此:

Cat** cat_array

与此相同:

Cat **cat_array

后者是首选,因为它更清楚指针指的是什么。例如,如果您有这样的声明:

int* a, b;

乍一看,似乎ab都是指针,而事实上只有a是指针。通过以下方式格式化它更明显:

int *a, b;