본문내용
void main(void)
{
FILE *src, *src2, *src3;
int type;
printf("Press the Number key < 1 or 2 > \n");
printf("1 : Encoding\n2 : Decoding\n");
scanf("%d", &type);
/* Encoding */
if (type == 1)
{
if ((src = fopen("hw2_2_orig_doc.txt", "rb")) == NULL)
{
printf("\n Error. That File can not Found.");
exit(1);
}
Huffman_Comp(src);
printf("\nCongratulation! File compressed.\n");
printf("Created 3 files.\n\n");
printf("(1)hw2_2_encoded.bin\n(2)hw2_2_codeword.txt\n(3)hw2_2_bin_tree.txt\n\n");
fclose(src);
}
/*Decoding*/
else if (type == 2)
{
if ((src2 = fopen("hw2_2_encoded.bin", "rb")) == NULL)
{
printf("\n Error. That File can not Found.");
exit(1);
}
if ((src3 = fopen("hw2_2_bin_tree.txt", "r")) == NULL)
{
printf("\n Error. That File can not Found.");
exit(1);
}
Huffman_Decomp(src2, src3);
printf("\nCongratulation! File decompressed & created.\n");
printf("Created 1 file.\n\n(1)hw2_2_decoded.txt\n\n");
fclose(src2);
fclose(src3);
}
else
printf("Please try Again.");
}
{
FILE *src, *src2, *src3;
int type;
printf("Press the Number key < 1 or 2 > \n");
printf("1 : Encoding\n2 : Decoding\n");
scanf("%d", &type);
/* Encoding */
if (type == 1)
{
if ((src = fopen("hw2_2_orig_doc.txt", "rb")) == NULL)
{
printf("\n Error. That File can not Found.");
exit(1);
}
Huffman_Comp(src);
printf("\nCongratulation! File compressed.\n");
printf("Created 3 files.\n\n");
printf("(1)hw2_2_encoded.bin\n(2)hw2_2_codeword.txt\n(3)hw2_2_bin_tree.txt\n\n");
fclose(src);
}
/*Decoding*/
else if (type == 2)
{
if ((src2 = fopen("hw2_2_encoded.bin", "rb")) == NULL)
{
printf("\n Error. That File can not Found.");
exit(1);
}
if ((src3 = fopen("hw2_2_bin_tree.txt", "r")) == NULL)
{
printf("\n Error. That File can not Found.");
exit(1);
}
Huffman_Decomp(src2, src3);
printf("\nCongratulation! File decompressed & created.\n");
printf("Created 1 file.\n\n(1)hw2_2_decoded.txt\n\n");
fclose(src2);
fclose(src3);
}
else
printf("Please try Again.");
}
소개글