I'm not really a fan of C, but I did homework for this exercise though. So far, what I got is that in C, initializing an array, as far as I know, is not like JavaScript. C has fixed arrays, and not initialized by a particular value. So NULL checking won't work in this case.
I have an array of structures. How would I know if that index in an array is empty or not (filled with a struct or not)?
#define LIST_LENGTH 30
//This is the struct that is inserted in the array
typedef struct node{
char fName[30];
char mName[30];
char lName[30];
char id[8];
} NODE;
typedef struct {
int size; //size is the struct's total capacity (at 30)
int length; //tracks how many elements are added, but not where
NODE nodes[LIST_LENGTH]; //This is the array in question
} List;
//somewhere in my code, I have to insert a value to the array at a specific position.
//if that position is occupied, I have to find the nearest empty position
//to the right, and shift the values rightward for that spot to be empty
Also, we are constrained to using arrays for this exercise. If we were granted to use linked-lists, this would be a walk in the park since we already know how to use dynamic lists.
How do I go about it? Or am I looking at the problem at the wrong angle (besides having to use arrays instead of linked-lists)?
>= lengthto be considered empty? Or is the array with "holes" ?