I am having the following situation, an array of structs passed to a function. So, inside function I'm dealing with double pointer. Now I am confused, it is working but I'm not sure why is it working on both ways(I like to try things out in different ways so I would get a better understanding of it).
The array is received as argument as: Rules **rules_array
Example 1:
rules_array = (Rules**) malloc(alloc_size*sizeof(Rules*));
By doing like in example 1, I would expect to make one more loop to allocate memory for all these structs(array elements) that are going to be pointed from Rules* elements, but obviously it's not needed and that's what I don't understand.
Example 2 (which makes more sense to me):
*rules_array = (Rules*) malloc(alloc_size*sizeof(Rules));
Thanks in advance!