Mail Archives: djgpp/1997/09/29/20:46:22
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 -