Dynamic array of structs and function call f(const struct_type *const data[])

前端 未结 4 1317
说谎
说谎 2021-01-15 20:09

The following code warns about incompatible type. What is the proper way to solve this code?

thanks

typedef struct a_struct struct_type;

void f(cons         


        
4条回答
  •  感动是毒
    2021-01-15 20:42

    See if this would work for you:

    f(struct_type *data);
    
    void test(unsigned n)
    {
        struct_type *v = malloc(n * sizeof(struct_type *));
        f(v);
    }
    

    Please let me know how you get on.

提交回复
热议问题