c - 三重指针警告

标签 c pointers structure

我收到了有关此代码的警告。

Warning { 

` del2_.c: In function ‘addIntoCell’:`

  `del2_.c:401:3: warning: passing argument 1 of ‘resizeArray’ from incompatible pointer type [enabled by default]`

  `del2_.c:378:6: note: expected ‘struct t_grapheVertex ***’ but argument is of type ‘struct  t_grapheVertex **`

}

这就是我定义函数的方式: void resizeArray(t_grapheVertex ***ele)

这是我调用该函数时的警告: resizeArray(&(*cell)->elements);

这是细胞的结构:

typedef struct st_cell
{
    int nbElements;
    struct st_cell* next;
    t_grapheVertex* elements;
} t_cell;


void resizeArray(t_grapheVertex ***ele){
    t_grapheVertex *temp;
    int newSize;
    newSize = arraySize*increaseRate ;
    temp = realloc(*ele , sizeof(int)*newSize);
    if(**ele == NULL)
    {
        printf("fail to resize\n");
        return;
    }
    else
    {
        printf("resized succesfully\n");
        **ele=temp;
        arraySize = newSize ;
    }
}

最佳答案

(*cell)->elements 给你一个指针,然后&符号给你一个double指针。同时,您期望 resizeArray() 函数有一个三重指针 - 您真的是这个意思吗?

如果可以的话,可以分享一下resizeArray的代码吗?

关于c - 三重指针警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19015267/

相关文章:

c - 如何将 NULL 附加到字符串指针数组的末尾?

c - 两个静态变量的相同内存位置分配

c++ - 帮助指针和传递链表作为参数, undefined reference C++

通过地址 C 调用函数

我可以将结构指针转换为指向 C1x 中的初始匿名成员吗?这甚至是正确的问题吗?

swift - 为什么常量约束来自结构实例而不是类实例的属性?

c - semaphore.h 中信号量的 pthread API 等效项

c++ - 运行 ShellExecuteEx 后获取线程退出码

c - NULL 指针 < 任何其他指针(NULL 除外)吗?

c - 为什么我的结构变量不包含这个成员?