So I'm trying to make an array of linked lists, at first I had the following code:
typedef struct node{
int data;
struct node *next;
} node;
struct ko {
struct node *first;
struct node *last;
} ;
struct ko array[6];
with this code the rest of the program runs fine, however, i would like the user to be able to define the array size when the program starts, after some research I believe it should be something like this:
the .h file
typedef struct node{
int data;
struct node *next;
} node;
struct ko {
struct node *first;
struct node *last;
} ;
struct ko *array;
the main.c file:
int size;
printf("array size: ");
scanf("%d", &size);
array = malloc(sizeof(struct ko) * size);
With this code the program compiles fine, but it just gets stuck when it runs, it doesn't crash, it just doesn't do anything... So I'm wondering if the problem is in this code, or elsewhere in the program.. thank you