示例#1
0
extern void compress_huffman(FILE *fin, char ArchiveName[200], int fileCount)
{
	unsigned long int *frequency = (unsigned long int*)calloc(CHARS_NUM, sizeof(unsigned long int));
	count_frequency(fin, frequency);
	huff_node_t *root = build_huff_tree(frequency);
	int
		**codes = (int**)malloc(CHARS_NUM * sizeof(int*)),
		*code_lengths = (int*)calloc(CHARS_NUM, sizeof(int));
	_codes(root, codes, code_lengths);

	FILE *fout = fopen(strncat(ArchiveName, ".vlt", 4), "w");
	fprintf(fout, "UPA File Archive\nsign: UPA\nHUFF\n1\n%d\n", fileCount);

	codify(fin, root, codes, code_lengths, fout);

}
示例#2
0
int main(int argc, char *argv[])
{
	int table[MAX], n;
	//Needs to be initialized to 0 so i can add correctly.
	int frequency[MAXNUMBER] = {0};

	//set pointers to them. Not really needed as they are pointers already (technically)
	int *table_p = table;
	int *frequency_p = frequency;

	create_random(table_p);
	count_frequency(frequency_p, table_p);
	draw_histogram(frequency_p);


	return 0;
}
int main ()
{
  //declaring variables
  int char_totals[num_of_letters];
  int num_of_lines = 0;
	
  //set all array values to zero 
  zeroed_out_array(char_totals, num_of_letters);

  //input data and alter array accordingly
  count_frequency (char_totals);
	
  //find the nuber of lines by finding the highest total
  num_of_lines = highest_pos_int_in_an_int_array (char_totals, num_of_letters);
	
  print_histogram(char_totals, num_of_lines);

  return 0; //to indicate no errors
}