From: Seby Carta Newsgroups: comp.os.msdos.djgpp Subject: Re: How to get file size? Date: Tue, 30 Sep 1997 01:24:19 +0100 Organization: Flashnet S.p.A. Lines: 33 Message-ID: <343046B3.90B361A8@sr.flashnet.it> References: <01bccc5b$8138ba00$0200a8c0 AT ingo> Reply-To: Seby Carta NNTP-Posting-Host: ip020.pool-21.flashnet.it Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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 . > So is there a standart way to get the number of chars in a file? > > Thanks to everyone who could help, > Ingo If you want the number of char, a good way is that , after loading file, count the character inside with a pointer...like this: char *Pointer; Pointer=begin_of_memory // where the file is loaded a cycle.... if (*Pointer>Min_Ascii_code && *Pointer++