here is a snippet of my code:
typedef struct node
{
char name[61];
int month;
int day;
int year;
struct node *next;
}node;
typedef struct list
{
node *head;
node *tail;
}list;
void main_menu(list* List)
{
//some code
}
int main(void)
{
main_menu(list* List); //Here is the error*****
return 0;
}
//But i need the 'list' initialization for these and some other functions in my code.
list *create_list(node *head)
{
some code//
}
list *insert_list(list *plist, node *pnode, node *new_node)
{
// some code
}
Copyright © 2024 1QUIZZ.COM - All rights reserved.
Answers & Comments
Declare typedef as follows
typedef struct
{
//members
} name;
Also you have another error, you have the method
void main_menu(list* List)
{
//some code
}
Now if you look at your "main" method you are not actually calling the method. I'm not positive 100% how the complier sees it but it probably thinks your statement "main_menu(list* List);" is a method declartion.
What you need to do is create a variable which is a list* struct.
list* myList = (list *) malloc(sizeof(list));
Then you can invoke the method by saying "main_menu(myList);"
I believe you need to declare List before you can send it as an argument
try:
list* List;
main_menu(List);
this is just a thought, I'm more of a C++ kinda guy but your function call seems wrong.
(if this is c++ then try it like this
Typedef struct list{
(stuff here)
List};