Docsity

C Programming Project: Circular Linked List Queues (ECE 329, Spring 2006), Study Guides, Projects, Research of Electrical and Electronics Engineering

Toggle sidebar
bg1
ECE 329
Spring 2006
Programming Project #1 โ€“ Queues
Due Date: 01-25-2006
Write a C module to implement queues with a circular linked list given the following
interface:
// type for a queue object
typedef struct queue *qtype;
// returns a new queue object
qtype Qinit();
// add an item to the queue
int Qadd(qtype q, void *data);
// remove an item from the queue
int Qremove(qtype q, void *data);
// return the head item of the queue
void *Qshow(qtype q);
// move the head item to the tail of the queue
// and return the new head item
void *Qnext(qtype q);
// free the given queue and all memory it is using
int Qfree(qtype q);
Functions returning a void * of qtype should return NULL on error; while functions
returning int should return -1 on error and zero on success. In the case of an error
the global variable errno should be set to the error code as shown below:
EQNOMEM // not enough memory to complete the operation
EQBADQ // argument is not a queue
EQNODATA // no data is available
EQUNKNOWN // any other error
You must turn in five files:
error.h : contains #defines for error codes and extern definition for errono
queue.h : contains the interface definition given above
queue.c : contains the implementation of the queue package
qtest.c: test harness that tests the queue package
queue.doc (pdf) : contains project report and documentation
Makefile : properly compile and link your project
Your code should be properly commented and tested. Your code should be entered in an
RCS or similar revision management database. Submit your assignment via email to:
[email protected] with the subject line: ECE329-1,#n user=userid, where
'n' is the assignment number. Must be sent via a Clemson mail server.

Partial preview of the text

Download C Programming Project: Circular Linked List Queues (ECE 329, Spring 2006) and more Study Guides, Projects, Research Electrical and Electronics Engineering in PDF only on Docsity!

ECE 329

Spring 2006 Programming Project #1 โ€“ Queues Due Date: 01-25- Write a C module to implement queues with a circular linked list given the following interface: // type for a queue object typedef struct queue *qtype; // returns a new queue object qtype Qinit(); // add an item to the queue int Qadd(qtype q, void *data); // remove an item from the queue int Qremove(qtype q, void *data); // return the head item of the queue void *Qshow(qtype q); // move the head item to the tail of the queue // and return the new head item void *Qnext(qtype q); // free the given queue and all memory it is using int Qfree(qtype q); Functions returning a void * of qtype should return NULL on error; while functions returning int should return -1 on error and zero on success. In the case of an error the global variable errno should be set to the error code as shown below: EQNOMEM // not enough memory to complete the operation EQBADQ // argument is not a queue EQNODATA // no data is available EQUNKNOWN // any other error You must turn in five files: error.h : contains #defines for error codes and extern definition for errono queue.h : contains the interface definition given above queue.c : contains the implementation of the queue package qtest.c: test harness that tests the queue package queue.doc (pdf) : contains project report and documentation Makefile : properly compile and link your project

Your code should be properly commented and tested. Your code should be entered in an

RCS or similar revision management database. Submit your assignment via email to:

[email protected] with the subject line: ECE329-1,#n user= userid , where

'n' is the assignment number. Must be sent via a Clemson mail server.