Browse Source

Add headers

master
Micah Halter 4 years ago
parent
commit
be30c2c8c4
3 changed files with 26 additions and 4 deletions
  1. +11
    -3
      huffman.c
  2. +7
    -0
      huffman.h
  3. +8
    -1
      main.c

+ 11
- 3
huffman.c View File

@@ -1,3 +1,11 @@
/*
============================================================================
Name : huffman.c
Author : Micah Halter
Version : 1.0
============================================================================
*/

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
@@ -192,7 +200,7 @@ struct NodeArray* getFrequency(char* filePath) {
//create new empty string as a character buffer to build integers
char* temp = malloc(1);
strcpy(temp, "");
//keep track or first and second previous characters to know if you are at a
//keep track or first and second previous characters to know if you are at a
//character or part of one of the numbers
int prevPrevChar = -1;
int prevChar = -1;
@@ -292,7 +300,7 @@ struct NodeArray* getFrequencyFile(char* filePath, char* outputPath) {
size++;
//convert the list of frequencies to an array of base nodes
struct NodeArray* freq = arrayFromList(list, size);
//check if an output file was passed
if(outputPath) {
//if so, open it for writing
@@ -335,7 +343,7 @@ struct NodeArray* arrayFromList(int* list, int size) {
freq->nodes[place++] = newBaseNode((int*) &i, list[i]);
//set the node array size to the passed in size
freq->size = size;
//return the node array
return freq;
}


+ 7
- 0
huffman.h View File

@@ -1,3 +1,10 @@
/*
* huffman
*
* Created on: May 30, 2015
* Author: micah
*/

#ifndef huffman
#define huffman



+ 8
- 1
main.c View File

@@ -1,3 +1,10 @@
/*
* main.c
*
* Created on: May 30, 2015
* Author: micah
*/

#include<stdio.h>
#include<unistd.h>
#include "huffman.h"
@@ -22,7 +29,7 @@ int main(int argc, char** argv) {
} else if(access(argv[1], F_OK ) == -1) {
//if not, print the file doesn't exist and return an exit code of 1
printf("%s does not exist\n", argv[1]);
return 1;
return 1;
}
//create unitialized variables to hold our node array and tree node
struct NodeArray* x;


Loading…
Cancel
Save