title: Reading from a file that has Fixed Length Records
body: <p>Suppose you've got a file that contains the following:</p>
  
  <ul>
  <li>A <strong>file header</strong> containing: a) the first empty record number, b) the size of each record, and c) the maximum number of records that the file can hold.</li>
  <li><strong>Records</strong> containing: a) a byte that indicates whether the record is free or occupied, b) a fixed number of fields.</li>
  </ul>
  
  <p>When I want to read a random record, I use this function:</p>
  
  <pre><code>int FixedLengthRecordFile :: read (int numRec, FixedLengthFieldsRecord &amp; rec) 
  </code></pre>
  
  <p>The problem is that, in order for this function to work, I must create a <code>FixedLengthFieldsRecord</code> beforehand, and this implies specifying the number of fields that this record has... which is not what I want. I want the file handler to be "smart" enough to recognize how many fields the record has, and to create a <code>FixedLengthFieldsRecord</code> on-the-fly as it reads it. </p>
  
  <p>How can I accomplish this? The function has to return an <code>int</code> because I use it as an exit code (error/success).</p>