delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1993/05/05/13:00:53

Date: Wed, 5 May 1993 09:37:54 -0700 (PDT)
From: Andrew Tucker <a_tucker AT paul DOT spu DOT edu>
Subject: Re: djgpp(gcc) equivalents to some bcc/tcc functions
To: "Wonkoo Kim, EE, U. of Pittsburgh" <WKIM AT vms DOT cis DOT pitt DOT edu>
Cc: djgpp AT sun DOT soe DOT clarkson DOT EDU

On Wed, 5 May 1993, Wonkoo Kim, EE, U. of Pittsburgh wrote:


> 	filelength()	determine the file size

This is probably the easiest to implement:

long filelength(FILE *fp) {

	long orig, size;

	orig = tell(fp);

	fseek(fp, 0L, SEEK_SET);
	size = fseek(fp, 0L, SEEK_END);
	fseek(fp, orig, SEEK_SET);
	return(size);
}

This will work on any ANSI C compiler and, of course, preserves the
original position of the file pointer.  You could write a similar routine
for file handles if need be.


/* Andrew */

"As far as the laws of mathematics refer to reality, they are not certain;
 and as far as they are certain, they do not refer to reality"
				Albert Einstein





- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019