Search code examples
arrayscpointersansi-c

Ansi C - function expecting pointer to array


im writting program in ANSI C, and and have one function, where im passing pointer to semaphores array struct sembuf semb[5].

Now header of that function looks like:

void setOperations(struct sembuf * op[5], int nr, int oper)

But im getting warning:

safe.c:20: note: expected ‘struct sembuf **’ but argument is of type ‘struct sembuf (*)[5]’

How to solve that problem?

Edit
Calling:

setOperations(&semb, prawa, -1);

Solution

  • This is how the function should be declared if you want to pass a pointer to an array and not an array of pointers:

    void setOperations(struct sembuf (*op)[5], int nr, int oper);