[prev] [index] [next]

A Linked List Implementation of a Quack

  • createQuack() creates a 'head' linked-list node that points to the quack.

// quackLL.c: a linked-list-based implementation of a quack
#include "quack.h"
#define HEADDATA -99999   // dummy data

struct _node {
	int data;
	struct _node *next;
};

Quack createQuack(void) {
	Quack head = (Quack)malloc(sizeof(struct _node));
	assert(head != NULL);
	head->data = HEADDATA;   // should never be used
	head->next = NULL;
	return head;
}