C function for an ADD operation

March 15, 2014 0 Comments

C function for an ADD operation:

void addlq(QUEUE *front, QUEUE *rear, int item)
QUEUE *temp = (QUEUE*) malloc (sizeof(QUEUE));
if (rear= =0)
{ rear=temp; front=temp; }
{ rear-->link=temp; rear=temp; }

To implement a Linear Queue using Linked List, in C, a self-referential struct QUEUE can be used similar to Linked List implemented STACK. The user define data type struct QUEUE contain one field to store the data say int i and the other field QUEUE *link to store the address of next node.
struct QUEUE
int i;
QUEUE *link;

Jackrin Reacher

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google