Hello,
I'm still a novice with this C programming and I got some problems with my program. I got 3 errors and 3 warnings with my Linked List. I attached an image for you to see. Someone can help me how to solve this problem?
Here's my code:
#include<stdio.h>
#include<stdlib.h>
void push(struct list *sList, int data);
void pop(struct list *sList);
void print(struct list *sList);
struct node
{
int data;
struct node *next;
};
struct list
{
struct node *start;
};
int main()
{
struct list *sList;
int i,cho=0;
do
{
printf("\n\n\n [1] Add Items\n");
printf(" [2] Display Items\n");
printf(" [3] Delete Items\n");
printf(" [4] Exit\n\n");
printf(" Enter your choice: ");
scanf("%d",&cho);
i = getchar();
if(cho==1)
{
push(sList,data);
}
else if(cho==2)
{
print(slist);
}
else if(cho==3)
{
pop(sList);
}
}
while(cho != 4);
{
clrscr();
printf("\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t ___________________\n\n\t\t\t Press Enter to Exit");
printf("\n\t\t\t ___________________");
i = getchar();
++i;
}
clrscr();
return 0;
}
void push(struct list *sList, int data);
{
sList->start = NULL;
struct node *p;
int n;
clrscr();
printf("\n\n Enter integer for total numbers to be allocated: ");
scanf("%d",&n);
printf("\n\n");
p = (struct node *)malloc(sizeof(struct node));
p->data = n;
p->next = sList->start;
sList->start = p;
}
void print(struct list *sList)
{
struct node *p = sList->start;
while(p != NULL)
{
printf("%d",p->data);
p=p->next;
}
}
void pop(struct list *sList)
{
if(sList->start != NULL)
{
struct node *p = sList->start;
sList->start = sList->start->next;
free(p);
}
}