I am having problems. I am currently learning C and have never used unions before. I have created the following union:
struct I_R_Record {
char Record_Type;
char Customer_code[6];
char Part_Number [7];
char Quantity [5];
};
struct Deletion_Record {
char Record_type;
char Customer_Code[6];
};
struct Creation_Record {
char Record_Type;
char Customer_Code [6];
char Customer_Name [21];
char Customer_Address[61];
float Customer_Balance;
long Credit_Limit;
};
union record {
struct I_R_Record I_R;
struct Deletion_Record Del;
struct Creation_Record cre;
};
But I dont know how to use it in a function. I have passed it to a function as follows:
/* Declaration */
void collect_record( FILE *file_ptr, union record *data );
then in main
collect_record( the_file, the_union );
but I dont know how to use it from this function. What I want to do is determine its type i.e. Record_Type. and then from this read the data in the appropriate way. Please could somebody tell me where I am getting stuck. Thanx