我是C的新手并试图从书中学习一些链表。我尝试编译此示例代码,但在下面获取这些警告。
警告
linkedlist.c:29:1:警告:隐式声明函数'display'[-Wimplicit-function-declaration] 显示器(安培;友好); ^ linkedlist.c:顶级: linkedlist.c:31:14:错误:未知类型名称'island'
提前感谢。
#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);
}
}