Code:
int make_fields( char *string_ptr, RECORD *data_ptr )
{
if( sscanf( string_ptr, "%c%5s%21s%61s%10s%8s",
&data_ptr->Cre.Record_Type,
data_ptr->Cre.Customer_Code,
data_ptr->Cre.Customer_Name,
data_ptr->Cre.Customer_Address,
data_ptr->Cre.Customer_Balance,
data_ptr->Cre.Credit_Limit) != 6 )
return ERROR;
else
return VALID;
}
The function is passed the address of the temporary string that took the line of data from the file using fgets() and RECORD *data_ptr points to the union that contains the various structures I require including the (Cre )one that I need for the example.
am I close on this or a million miles off?