It's my First Program using circuar singly linklist
typedef struct clist
{
int data;
struct clist *next;
}CLIST;
CLIST *cp = NULL;
Add new node function
void add(int num)
{
CLIST *r;
r = malloc (sizeof (CLIST));
if (!r)
{
printf("\n\n Not Enough Memory");
return;
}
r->data = num;
if (!cp)
{
cp = r;
cp->next = cp;
}
else
{
r->next = cp->next;
cp->next = r;
cp = r;
}
}
And Display Function
void display()
{
CLIST *temp;
temp = cp;
if (!cp)
{
printf("\n Empty!!");
return;
}
do
{
temp = temp->next;
printf("\n %d",temp->data);
}while (temp != cp);
}
IS IT CORRECT??
Also it's showing one warning
warning: incompatible implicit declaration of built-in function 'malloc'
Why?