[英]warning: implicit declaration of function ‘strcpy’ [-Wimplicit-function-declaration] the program work but how i fix the compiler error
[英]How do i fix this error? warning: implicit declaration of function ‘main_menu’
這是利用鏈表的b天提醒代碼
typedef struct node
{
char name[61];
int month; int day;
int year;
struct node *next;
}node;
這是清單
typedef struct list
{
node *head;
node *tail;
}list;
這是創建列表代碼
list *create_list(list *plist)
{
plist->head = NULL;
plist->tail = NULL;
return plist;
}
這會將創建的節點插入列表
list *insert_list(list *plist, node *pnode, node *new_node)
{
new_node->next = pnode->next;
pnode->next = new_node;
if (plist->tail == pnode)
{
plist->tail = new_node;
}
}
這是添加生日菜單
void add_birthday(list *List)
{
char x;
node *data = (node *) malloc(sizeof(node));
List = (list*) malloc(sizeof(list));
printf("******************************************************************\n");
printf(" ADD BIRTHDAY REMINDER FORM\n");
printf("******************************************************************\n");
List = insert_list(List, data, create_node(data));
printf("Would you like to add another(y/n)?\n");
scanf("%c", &x);
if (x=='y')
{
while (x=='y')
{
if (x=='y')
{
getchar();
printf("******************************************************************\n");
node *data = (node *) malloc(sizeof(node));
List = insert_list(List, data, create_node(data));
printf("Would you like to add another(y/n)?\n");
scanf("%c", &x);
}
}
}
main_menu(List); //the problem lies here
}
這是主菜單
void main_menu(list* List)
{
int x;
printf("Welcome to myCalendar version 1.0.0\n");
printf("Please input the number that you wish to do:\n");
printf("[1] Add Birthday Reminder\n");
printf("[2] Delete Birthday Reminder\n");
printf("[3] View Calendar\n");
printf("[4] Quit\n");
scanf("%d", &x);
getchar();
switch (x)
{
case 1:
add_birthday(List);
break;
case 2:
delete_reminder(List);
break;
case 3:
view_calendar(List);
break;
case 4:
free(List);
break;
}
}
這是主要的
int main(void)
{
list* List = (list*) malloc(sizeof(list));
List = create_list(List);
main_menu(List);
return 0;
}
是這樣定義的main_menu()
是后add_birthday()
如果是定義main_menu()
之前add_birthday()
還要在main()
之前定義所有方法,或者在main()
之前至少聲明它們。
您沒有將包含main.menu()聲明的* .h包含在包含main()或add_birthday()的* .c中,也沒有將錯誤指向任何地方。
您聲明了main_menu嗎? 在沒有聲明的情況下,假定函數返回“ int”。 但是,函數定義說,它正在返回void。 這是所有混亂的原因。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.