help with c project using qsort
How do you use qsort on a text file of different length records(when you have to sort two things(record type(first character) and customer_code(chars 2-6))) when the data is in structures inside a union?
e.g.:
Code:
struct i_r_record{
char rec_type,
cust_code[5],
part_num[6],
i_r_qty[4];
};
struct c_record{
char rec_type,
cust_code[5],
cust_name[20],
cust_address[60],
cust_bal[9],
cust_limit[7];
};
struct d_record{
char rec_type,
cust_code[5];
};
union records {
struct i_r_records i;
struct c_records c;
struct d_records d;
};
[code][/code]tagged by Salem
I just thought.........................
I have just thought......I have to write a function/loop to count the number of records BEFORE i can read them into an array of unions, so how can I then set the size of an array of unions before I know the numbwer of records?:confused: