How do I do this? For example
typedef struct node
{ int data;
struct node* next;
}node;
Is my node, and in my main I have
int main(){
node* array[10];
if (node[0].data == 0){
...
}
I am not really sure what I need to do here. I want to be able to check if these entries in the array have been modified already. How would I do this? I have tried the -> operator instead of . which is causing me some confusion because I am working with an object aren't I? I am uncertain of this.
Following advice this is what I now have.
int main() {
struct node* arr[10] = { 0 } ;
addTo(data, arr);
}
addTo(int data, node* arr){
if (arr[0] == NULL)
}
The last line is a segmentation fault.
struct node* arr[10];declares an array of 10 pointers, but doesn't initialize those pointers to valid memory. You meantstruct node arr[10];to get an array of actual structures.hashT[n]? you need to use with arr[n] instead. As @unwind said allocate memory or other wise declare struct node arr[10].