I am attempting to read a binary file to my screen. It loads fine but prints the last record twice. I've exhausted many possibilities but apparently not the right one! Below is the code I'm using. Thanks for the help.
inp = fopen(file_name, "rb"
do
{
fread(&partrecord, sizeof(part), 1, inp);
printf("%s %-20s %.2f %-d %-d %d
%d/%d/%d\n",
partrecord.part_id, partrecord.part_descr,
partrecord.unit_price, partrecord.quan_onhand,
partrecord.reodr_pt,partrecord.reodr_qty,
partrecord.reodr_date.month,
partrecord.reodr_date.day,
partrecord.reodr_date.year);
}while (!feof(inp));
fclose(inp);
inp = fopen(file_name, "rb"
do
{
fread(&partrecord, sizeof(part), 1, inp);
printf("%s %-20s %.2f %-d %-d %d
%d/%d/%d\n",
partrecord.part_id, partrecord.part_descr,
partrecord.unit_price, partrecord.quan_onhand,
partrecord.reodr_pt,partrecord.reodr_qty,
partrecord.reodr_date.month,
partrecord.reodr_date.day,
partrecord.reodr_date.year);
}while (!feof(inp));
fclose(inp);