I have a flat file with the ff data:
date;quantity;price;item
I want create a data record using the following struct:
typedef struct {
char * date, * item;
int quantity;
float price, total;
} expense_record;
I created the following initializing method:
expense_record initialize(char * date, int quantity, char *price, char *item) {
expense_record e;
e.date = date;
e.quantity = quantity;
e.item = item;
/* set price */
return e;
}
My question is how to set the price as float
(as required by the struct) from the char *price
. The closest I got, i.e. without generating a compiler error was
e.price = *(float *)price
but this results in segmentation faults.
Thanks!