I am trying to create an empty node without affecting the pointer which points on the head of the connected list/node. So, is there is any problem in my code?
CellPtr Create_Node(CellPtr created, int size)
{
CellPtr head;
int i;
if((created=(CellPtr)malloc(sizeof(Cell)))==NULL)
{
printf("Allocation Error");
exit(1);
}
head=created;
for(i=0; i<size-1; i++)
{
if((created->next=(CellPtr)malloc(sizeof(Cell)))==NULL)
{
printf("Allocation Error");
exit(1);
}
created=created->next;
}
created->next=NULL;
return head;
}