I'm trying to run a function, but gets Undefined reference 'createList'.
#include <stdio.h>>
#include <stdlib.h>
void createList();
struct node{
int classList;
struct node *next;
}*Node;
int main()
{
struct node *head = NULL;
int choice, n, info;
int classList;
printf("* ****Select an option from menu**** \n");
printf("1. Create List\n");
printf("2. Display List\n");
printf("3. Insert List\n");
printf("4. Remove List\n");
printf("5. Search List\n");
printf("6. Exit");
scanf("%d", &choice);
switch(choice)
{
case 1: createList();
break;
/*case 2: displayList();
break;
case 3: insertList();
break;
case 4: removeList();
break;
case 5: searchList(n);
break;
case 6: printf("Exit");
break;*/
}
void createList()
{
struct node *ptr, *tmp;
if(Node == NULL)
{
Node = (struct node *)malloc(sizeof(struct node));
Node ->classList = info;
Node ->next=NULL;
}
else
{
printf("Enter data for list 1: \n");
scanf("%d", &classList);
ptr = Node;
while(ptr != NULL)
{
ptr = ptr ->next;
}
tmp = (struct node *)malloc(sizeof(struct node));
tmp->classList=info;
tmp->next=NULL;
ptr->next=tmp;
}
}
}
j
stuff ;)
why do you define create list in in
int main? also#include <stdio.h>>has one > to many.