I've looked everywhere trying to figure out what I'm doing wrong and can't seem to figure out WHY this block of code isn't handling hexadecimal numbers correctly.
FILE *listFile = fopen(argv[1], "r");
unsigned int hexIndex;
if(listFile == NULL){
printf("error\n");
return 0;
}
while(!feof(listFile))
{
fscanf(listFile, "%x\n", &hexIndex);
printf("hexindex %d\n", hexIndex);
if(hashInsert(hexIndex) == 0)
{
printf("uniques: %d\n", uniques);
uniques++;
}
}
For example, given a file with the following 3 hexadecimal addresses:
0xFFFFFFFFFF
0x7f1a91026b00
0x7f1a91026b03
The program prints out:
hexindex -1
hexindex -1862112512
hexindex -1862112509
which I'm 100% sure is incorrect. I've spent hours trying to figure out what I've done wrong, and I feel that I might be overlooking something simple. I've tried using different integer types like size_t, longs, etc. but run into the same exact output every time.
Can anybody give me some insight as to what I might be doing wrong?