The first section contains declarations we will use to create and traverse the doubly linked list, as follows:
#include <stdlib.h>
struct Node {
int id;
int categoryId;
float rawAmount;
float cookedAmount;
struct Node *next;
struct Node *prev;
};
typedef enum {
RAW = 1,
COOKED = 2
} AmountType;
struct Node *transactionsHead = NULL;
struct Node *categoriesHead = NULL;
The Node struct is used to represent a transaction or category. The transactionsHead and categoriesHead node instances represent the first node in each linked list we'll use (one for transactions and one for categories). The AmountType theĀ enum isn't required, but we'll discuss how it's useful when we get to the section of code that utilizes it.