length is initialized to the number of fields in each record

int length = 3, i;