Beispiel #1
0
// Driver program to test above functions
int main()
{
    char arr[] = {'a', 'b', 'c', 'd', 'e', 'f'};
    int freq[] = {5, 9, 12, 13, 16, 45};
    int size = sizeof(arr)/sizeof(arr[0]);
    HuffmanCodes(arr, freq, size);
    return 0;
}
int main (void)
{
	int i;
	fp = fopen ("dictionary.dic", "w");
	if (fp == NULL)
	{
		printf("Error!");
		exit(1);
	}
	char* src = loadFile();
	int inp_l = strlen(src) - 1;
	char* inp = malloc (inp_l); stringcopy(inp,src,inp_l);
	char* inp_c = malloc (inp_l); stringcopy(inp_c,src,inp_l);
	int size = no_of_distinct_char(inp, inp_l);
	char* arr = (char*)malloc(size*sizeof(char));
	int* freq = (int*)malloc(size*sizeof(int));
	createCharFreqArray(inp_c, inp_l, arr, freq, size);
	HuffmanCodes(arr, freq, size);
	fclose(fp);
	free(src);
	return 0;
}