You are having a segmentation fault because a float
have 4 Bytes: when you make *(float *)price
you are accesing to the first 4 Bytes of price, so if price´s size is smaller than 4 chars, you will have an error.
I think that the best you can do is read a float
instead a char *
when you parse the data (as i supose yo do with quantity), for example fscanf (pFile, "%s;%d;%f;%s", &date, &quantity, &price, &item);
or convert to float
in initialize
with strtod instead of make a cast.