Hi. I have a bit of a problem with this code:
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
main () {
FILE *data;
char let;
int prior, ctr;
data = fopen("huffman_table.txt", "r");
while (fscanf(data, "%c%d\n",&let, &prior)!='\0') {
printf("\nLetter: %c Priority: %d", let, prior);
}
fclose(data);
getche();
}
The huffman_table.txt contains the content:
B1
H1
J4
G5
F6
C7
I8
A9
D9
E10
The code works well until the last line. My program ended up having endless loops with "E10". I double-checked the txt file and it is completely fine. Any help with the code is much appreciated! :)
*btw, i am required to use fscanf to read the content.