huffman

huffman coding implementation in C
Log | Files | Refs | README | LICENSE

commit 2a219554ce92704800ba237c253d822f2e1e0a6a
parent 24330bba87dcced608759888a0b7f5d8187cafb9
Author: tin <ichtinnotl@gmail.com>
Date:   Sun, 28 Oct 2018 19:03:46 +0100

create and delete nodes

Diffstat:
huffman.c | 34+++++++++++++++++++++++++++++++---
huffman.h | 20++++++++++++++++++++
2 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/huffman.c b/huffman.c @@ -1,6 +1,35 @@ #include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "huffman.h" + +node * +create_node(const char c, const int f) { + node * n = malloc(sizeof(node)); + + n->character = c; + n->frequency = f; + n->left = n->right = NULL; + + return n; +} + +void +delete_node(node * n) { + if (n->left) free(n->left); + if (n->right) free(n->right); + + free(n); +} int main () { - printf("Initial. :)") -}- \ No newline at end of file + int f = 1; + char c = 'a'; + + node * n = create_node(c, f); + delete_node(n); + + exit(0); +} diff --git a/huffman.h b/huffman.h @@ -0,0 +1,20 @@ +typedef struct { + char character; + int frequency; + + struct node * left; + struct node * right; + +} node; + +node * +create_node(const char c, const int f); + +void +delete_node(node * n); + + + + + +