I'm trying to take an external input file and perform operations onto it. The file is a bunch of HEX code that I want to sum up. Using the following function (declared in the program previously):

/************************
* open the input file *
************************/

void file(void)
{
hex= fopen("EProm0109-0502.HEX", "r");
if (hex == NULL)
{
printf("Error, file is not found. \n");
exit(1);
}
}

in my main program, i try and call this by using the following command:

while(fscanf(hex, "%d", hexstr) != EOF)
{
printf("%d\n", hexstr);
}

What am I doing wrong? Also, how can i get the numbers to read out as hex numbers, not decimal as %d would seem to indicate or a string as %s would imply?