I have written a program which updates a master file using a transaction file and creates a new generation of the master file.
I ran the program and cannot get rid of 3 errors - can you give me any clues on how to solve these.
The basic set up of my program is:
char cust_code ;
char part_no; /*Have to be char for previous prog*/
char quantity ;
char balance ;
char limit ;
struct record old;
struct record2 create;
char code ;
char blah ;
union account details;
I want to put the 'balance' from the transaction struct record2 into 'cust_bal' in the master struct. The follwing gave me an error:
master_rec_ptr->cust_bal = cust_rec_ptr->details.create.balance;
Type casting (float) doesn't work. What is another way to do this without getting an error re: type incompatibility?
I also want to put the 'limit' from the trans into 'credit_limit' in the master.
master_rec_ptr->credit_limit = cust_rec_ptr->details.create.limit;
This time error is non portable pointer conversion.
The following are already set up in a header file. An indexed file so that using the part number you can find the record required.
char key ;
char key ;
unsigned long rec_num;
A function to read the file is also included in the header file.
The prototype for the function is:
static RECORD_DATA *search_file(char *product_code);
The function is passed the product code and searches the file returning a pointer to the appropriate data structure.
I have therefore written:
float value = 0.0;
if((stock_rec = search_file(cust_rec_ptr->details.old.part_no)) != NULL)
/*the next line is where I get the error*/
value = (float)cust_rec_ptr->details.old.quantity * stock_rec->price;
I'm wanting to multiply the quantity from the transaction file with the stock price. Again the type incompatibility.
Any help much appreciated.