ftell fseek II (sva)

vanaards%t7 at uk.ac.man.cs vanaards%t7 at uk.ac.man.cs
Sat Dec 15 00:38:48 AEST 1990


  What is the quickest way of determining the size of a file using Standard
ANSI C functions ? Currently I'm using fseek to locate the end of file, 
followed by ftell to interrogate the position index.

  Also, I'm having to read strings from a file - well full file path-names,
now in a hierarchial structured system these vary in size according to the
location of the file. The format of the file is defined as :

  full-filename   number  full-filename number number \n 

  When reading strings it seems you have to allocate an array (buffer) whose
size will cater for the largest string possible - but in my case that isn't
exactly possible. Apart from reading chars using fgetc either on a two pass
basis - first pass to determine length, and second to fill a dynamically
allocated buffer, or reading into a linked list - how would you recommend that
I get the best performance ?
 

+--------------------------------+-----------------------------------------+
|   ()()TEVEN         ()         |  Are you sure it isn't time for another |
|  ()                ()()        | colorful metaphor?   -- Spock,          |
|   ()()   ()  ()AN ()  ()       | "The Voyage Home,"  stardate 8390.      |
|      ()   ()()   ()()()()      +-----------------------------------------+
|   ()()     ()   ()      ()ARDT |JANET E-mail : vanaards at uk.ac.man.cs.p4  |
+--------------------------------+-----------------------------------------+



More information about the Comp.lang.c mailing list