简体   繁体   English

我该如何解决此错误? 警告:函数“ main_menu”的隐式声明

[英]How do i fix this error? warning: implicit declaration of function ‘main_menu’

this is a b-day reminder code utilizing linkedlists 这是利用链表的b天提醒代码

typedef struct node  
{  
    char name[61];  
    int month;          int day;  
    int year;  
    struct node *next;  
}node;  

this is the list 这是清单

typedef struct list  
{  
    node *head;  
    node *tail;  
}list;  

this is the create list code 这是创建列表代码

list *create_list(list *plist)  
{  
    plist->head = NULL;  
    plist->tail = NULL;  
    return plist;  
}  

this inserts the node created to the list 这会将创建的节点插入列表

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;  
    }  
}  

this is the add birthday menu 这是添加生日菜单

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
}  

this is the main menu 这是主菜单

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;  
        }  
}

this is the main 这是主要的

int main(void)  
{  
    list* List = (list*) malloc(sizeof(list));  
    List = create_list(List);  
    main_menu(List);  
    return 0;  
}  

Is the definition of main_menu() is after add_birthday() ? 是这样定义的main_menu()是后add_birthday() If yes define main_menu() before add_birthday() . 如果是定义main_menu()之前add_birthday() Also define all the methods before main() or atleast declare them before main() . 还要在main()之前定义所有方法,或者在main()之前至少声明它们。

您没有将包含main.menu()声明的* .h包含在包含main()或add_birthday()的* .c中,也没有将错误指向任何地方。

Have you declared main_menu? 您声明了main_menu吗? In the absence of declaration a function is assumed to return 'int'. 在没有声明的情况下,假定函数返回“ int”。 But, you function definition says, it is returning void. 但是,函数定义说,它正在返回void。 This is the cause of all the confusion. 这是所有混乱的原因。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 警告:function 'strcpy' [-Wimplicit-function-declaration] 的隐式声明程序工作,但我如何修复编译器错误 - warning: implicit declaration of function ‘strcpy’ [-Wimplicit-function-declaration] the program work but how i fix the compiler error 如何解决“函数的隐式声明” - How to fix “ implicit declaration of function” 为什么我会收到警告“隐式声明 function 'fopen_s'”,我该如何摆脱它? - Why do I get a warning “implicit declaration of function 'fopen_s'” and how can I get rid of it? 警告:function 的隐式声明 - warning: implicit declaration of function 我正在使用 Linux,用 gcc 编译,收到错误:警告:函数 'fopen_s' 的隐式声明,有人可以帮我解决这个问题吗? - I'm using Linux, compiling with gcc, getting error: warning: implicit declaration of function ‘fopen_s’, can someone help me fix this? 如何删除“不兼容的隐式声明”警告 - How do I remove “incompatible implicit declaration” warning 如何修复 C 中的错误或警告:“函数‘inet_aton’的隐式声明;你的意思是‘inet_pton’吗?” - How to fix error or warning in C: "implicit declaration of function ‘inet_aton’; did you mean ‘inet_pton’?" 警告:函数的隐式声明 - warning: implicit declaration of function 如何删除以下“函数的隐式声明”警告? - How do I remove the following 'implicit declaration of function' warnings? 警告:隐含声明 function 'vasprintf'? - Warning: implicit declaration of function ‘vasprintf’?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM