cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/29/20:46:22

From: Seby Carta <cartas AT ita DOT flashnet DOT it>
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 <cartas AT ita DOT flashnet DOT it>
NNTP-Posting-Host: ip020.pool-21.flashnet.it
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?
>
> 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++<Max_ascii_code) Num_Char++;

 end of cycle.

Seby.

- Raw text -


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