MCPcopy Create free account
hub / github.com/algorithm-archivists/algorithm-archive / main

Function main

contents/huffman_encoding/code/c/huffman.c:250–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

248}
249
250int main() {
251 struct tree* tree;
252 struct codebook codebook;
253
254 char* encoded = encode("bibbity bobbity", &tree, &codebook);
255 char* decoded = decode(encoded, tree);
256
257 printf("Codebook:\n");
258 for (int i = 0; i < 256; ++i) {
259 if (codebook.codes[i]) {
260 printf("%c %s\n", (char)i, codebook.codes[i]);
261 }
262 }
263
264 printf("%s\n", encoded);
265 printf("%s\n", decoded);
266
267 tree_free(tree);
268 codebook_free(&codebook);
269 free(encoded);
270 free(decoded);
271 return 0;
272}

Callers

nothing calls this directly

Calls 4

tree_freeFunction · 0.85
codebook_freeFunction · 0.85
encodeFunction · 0.70
decodeFunction · 0.70

Tested by

no test coverage detected