Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!mucs!cns!usenet From: vanaards%t7@uk.ac.man.cs Newsgroups: comp.lang.c Subject: ftell fseek II (sva) Keywords: ftell fseek r+ Message-ID: <1990Dec14.133848.14932@cns.umist.ac.uk> Date: 14 Dec 90 13:38:48 GMT References: Sender: usenet@cns.umist.ac.uk (News System) Organization: Department of Computer Science, University of Manchester UK Lines: 26 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@uk.ac.man.cs.p4 | +--------------------------------+-----------------------------------------+