www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/30/14:30:55

From: "A. Sinan Unur" <sinan DOT unur AT cornell DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: How to get file size?
Date: Mon, 29 Sep 1997 16:39:49 -0500
Organization: Cornell University
Lines: 17
Sender: asu1 AT cornell DOT edu (Verified)
Message-ID: <34302025.7E59@cornell.edu>
References: <01bccc5b$8138ba00$0200a8c0 AT ingo>
Reply-To: sinan DOT unur AT cornell DOT edu
NNTP-Posting-Host: 128
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Ingo Ruhnke wrote:
> 
> I want to read a ASCII Text file, therefore I do allocate some memory 
> with malloc() and therefore I need the filesize, more exactly the 
> number of characters. At the moment I use this to get the file size:
> 
> filelength(fileno(FILE *))
> 
> This returns me the number of bytes of the file, but the number of 
> chars is a little bit smaller, because of the <LF><CR>.
>
> So is there a standart way to get the number of chars in a file?

i wouldn't think so... at least not without reading in the whole file
first. what is the problem with reserving space for a few extra bytes?

  -- Sinan

- Raw text -


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