I need to keep numbers of linked-lists in an array. I have followed similar questions but confused about implementation and cannot allocate the array correctly. I debugged, found, and simplified my problem: The array is always sized as 1
instead of N
. As a result, I'm getting segmentation fault when try to use nodes. Simplified code:
typedef struct Node {
int data;
struct Node *next;
} node;
int main(int argc, char** argv)
{
node **array;
int N = 5;
array = (node **)calloc(N,sizeof(node*));
printf("Size of array = %d", sizeof(array)/sizeof(array[0]));
return 0;
}
And the output is:
Size of array = 1
Here when I use static size for array as node *array[5]
the output is:
Size of array = 5
Thanks for suggestions.