Question: Please explain each line of codes. It's queue lab in C * This program implements a queue supporting both FIFO and LIFO * operations. *

Please explain each line of codes. It's queue lab in C

* This program implements a queue supporting both FIFO and LIFO 
 * operations. 
 * 
 * It uses a singly-linked list to represent the set of queue elements 
 */ 
 
#include  
#include  
#include  
 
#include "harness.h" 
#include "queue.h" 
 
/* 
 Create empty queue. 
 Return NULL if could not allocate space. 
*/ 
 1. queue_t *q_new() 
 2. 3. { 4. queue_t *q = malloc(sizeof(queue_t)); 5. /* What if malloc returned NULL? */ 
 6. if (q == NULL) 
 7. return q; 8. q->head = NULL; 9. q->tail = NULL; 10. q->n = 0; 11. return q; 12. }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!