我该如何解决这个错误?警告:函数 'MAIN_MENU' 的隐式声明

我该如何解决这个错误?警告:函数 'MAIN_MENU' 的隐式声明

问题描述:

这是利用linkedlists我该如何解决这个错误?警告:函数 'MAIN_MENU' 的隐式声明

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

这是列表

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

A B天提醒码这是创建列表代码

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

这些都是警告test.c的:290:警告:函数 'MAIN_MENU' test.c的隐式声明:在顶层: test.c的:357:警告:冲突的类型 'MAIN_MENU' test.c的:290:note:以前的隐式声明'main_menu'在这里 – user123456098 2012-03-29 04:41:40

main_menu()的定义是在add_birthday()之后?如果是,则在add_birthday()之前定义main_menu()。还要定义main()之前的所有方法或至少在main()之前声明它们。

+0

非常感谢:D – user123456098 2012-03-29 08:52:44

+1

然后接受答案.. – Parag 2012-03-29 09:25:50

+0

哦,对不起,关于我只是新来的 – user123456098 2012-03-31 12:15:43

你不包括*含.H MAIN_MENU( )声明到* .c中,包含main()或add_birthday()或任何指向错误的地方。

您是否声明了main_menu?在没有声明的情况下,假定函数返回'int'。但是,你的函数定义说,它是无效的。这是所有混乱的原因。