Subj : Re: newbie question [C language] To : comp.programming From : websnarf Date : Fri Jul 01 2005 08:34 pm Fred_NacH wrote: > I was wondering, how to retrieve the size/length of a file by only using > the ansi functions... The C language has a problem where the size of file that can be defined by the platform can exceed the largest integer size that the language itself supports. This is clearly a serious issue for 32-bit OSes that support 64 bit files. So using functions like ftell() or even (f)stat() is not really guaranteed to work. In fact I have no idea what a programmer should expect ftell() to ever tell them. On Windows systems, int is usually defined as 32-bits, and ftell() returns an int, however clearly the OS supports 64-bit files. Your system may support a function like _fstati64(), or some other similar function which is more likely to give you want you are looking for. On a couple Windows compilers I use, _fstati64() outputs to a structure which is syntactically equivalent to the posix structure struct stat, though it may contain additional reserved entries and will define st_size as __int64. Of course the size of a "directory" or abstract file (such as "con") does really make any sense, but you can use the st_mode entry to figure out whether or not you have accessed an ordinary file or not. -- Paul Hsieh http://www.pobox.com/~qed/ http://bstring.sf.net/ .