Thursday 15 August 2013

How to sniff the number of records in a binary file before reading into an array in the C programming language? -


How do I tell in a better way how many records I see in the binary file before opening a file, for example an array Records in?

  MyFile = Fopen ("DATA.dat", "rb"); I = 0; While (Fifi (MyFile) == 0) {FREED (& amp; Temple readings record, size (tempReadingRecord), 1, file); If (ff (mimefile) == 0 {i ++;}} fclose (MyFile);} printf ("% d", i); / * how many records works to find but optimal? * /   

has an arbitrary number of NULS attached at its end) but you will not run into problems on the most common systems (APAI, which was mainly on CP / M, Since the block was not stored, only several blocks, so the end of the file was always padded to fill the last block).

BTW, your loop is a problem to read the record - in fact, sort Almost any loop while ((Fif (file)) , or nothing is guaranteed to work with similar incorrectly (usually it will "last record Twi read" CE).


No comments:

Post a Comment