Question

Here's my problem: I need to implement a FIFO/LIFO list stack as ADT species 1. My program is modular and it have an item.h module:

    #ifndef ITEM_H_INCLUDED
    #define ITEM_H_INCLUDED

    typedef struct
    {
        char stringa[20];
        int numero;
    } Item;        
    #endif // ITEM_H_INCLUDED

The head.h module:

#ifndef HEAD_H_INCLUDED
#define HEAD_H_INCLUDED

#include <stdio.h>
#include <stdlib.h>

#include "item.h"  

void QUEUEinit();
int QUEUEempty();
void QUEUEput_top(Item);
void QUEUEput_bottom(Item);
Item QUEUEget_top();
Item QUEUEget_bottom();

#endif // HEAD_H_INCLUDED

The main.c and data.c; what i need is how i declare a QEUEnode struct and where.

Thank you for the help :)

Was it helpful?

Solution

Since none of your QUEUE* functions receive a QUEUEnode *, you can hide it in the head.c file, along with the QUEUEnode root; that they operate on.

If you want to use multiple queues, then it should probably be in the head.h file so they can be created in main.c. For this, you'll also need to modify the functions to accept a queue to operate on.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top