I'm trying to write a program that user can create linked-list by entering the number of lists they want to create but when i ran this code it doesn't work.
Can someone please help me?
Code:
#include <stdio.h>
#include <malloc.h>>
#include <stdlib.h>
void createList();
struct node *cList;
int main()
{
void createList();
cList = NULL;
struct node
{
int studentId, age, choice, cList;
char studentName[30];
struct node *next;
};
int choice;
printf("Please select an option: ");
printf("1. Create\n");
/* printf("2. Display\n");
printf("3. Insert\n");
printf("4. Remove\n");
printf("5. Search");
printf("6. Exist");*/
scanf("%d", &choice);
switch(choice)
{
case 1: createList();
}
}
void createList()
{
char list;
if(cList == NULL)
{
struct *newNode, *current;
newNode = (struct node *)malloc(sizeof(struct node));
printf("Enter the number of list: \n");
scanf("%d", &newNode -> data);
newNode ->next = NULL;
if(cList == NULL)
{
cList = newNode;
current = newNode;
}
else
{
current ->next = newNode;
current = newNode;
}
printf("Would you like to create another list?\n");
list = getch();
}
}