I'm new to C and trying to learn some linked list from a book. I try to compile this example code but get those warnings below.
warnings
linkedlist.c:29:1: warning: implicit declaration of function ‘display’ [-Wimplicit-function-declaration] display(&amity); ^ linkedlist.c: At top level: linkedlist.c:31:14: error: unknown type name ‘island’
thanks in advance.
#include<stdio.h>
#include<string.h>
int main(){
typedef struct island{
char *name;
char *opens;
char *close;
struct island *next;
}island;
island amity = { "Amity" , "09:00", "17:00", NULL};
island craggy = { "Craggy" , "09:00", "17:00", NULL};
island isla_nublar = { "isla Nublar" , "09:00", "17:00", NULL};
island sutter = { "Shutter" , "09:00", "17:00", NULL};
amity.next = &craggy;
craggy.next = &isla_nablar;
isla_nabla.next = &shutter;
island skull = { "Skull" , "09:00", "17:00", NULL};
isla_nabla.next = &skull;
skull.next = &shutter;
display(&amity);
}
void display(island *start){
island *i = start;
for(; i != NULL; i = i->next){
printf("NAme: %s open : %s-%s\n", i->name,i->opens,i->close);
}
}