3

Could someone tell me if this answer is correct!? I'm not sure about the allocation of the second struct:

struct dyn_array my_array = malloc(sizeof(struct dyn_array) + 100 * sizeof(int));

Shouldn't my_array be a pointer, like this:

struct dyn_array *my_array = malloc(sizeof(struct dyn_array) + 100 * sizeof(int));

4
  • 5
    Yes, it should be a pointer. Commented Jun 1, 2017 at 20:06
  • you are correct. It seems typo. Commented Jun 1, 2017 at 20:06
  • 1
    Yes. It's been fixed. Commented Jun 1, 2017 at 20:06
  • I'm voting to close this question as off-topic because it should be a comment Commented Aug 21, 2018 at 5:29

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.