0

I'm having trouble interpreting this sentence into code: A function called max_occurences() that has a pointer to an array of struct occurrences as an argument.

My understanding is that they mean something like this:

int max_occurences(struct occurrence *occurrences[])

But this appears to be wrong. Can someone help me understand what it's suppose to look like? I'm really confused.

1
  • 2
    Thats an array of pointers to structs (2 level of indirection). You should just lose either the * or the []. You may also want to pass a length value to indicate how many items are in your array. Unless of course its terminated with some sort of sentinel value. Commented Apr 27, 2017 at 4:14

1 Answer 1

1
int max_occurences(struct occurrence *occurrences[])

The argument here is array of pointers to struct occurrence.

A pointer to an array of struct occurrence would be declared as -

struct occurrence (*occurrences)[3];  

So your argument should be -

int max_occurences(struct occurrence (*occurrences)[])
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.