Message-ID: <3D0EF1F1.1070202@eik.bme.hu> Date: Tue, 18 Jun 2002 10:40:17 +0200 From: =?ISO-8859-2?Q?=22Dr=2E_Andr=E1s_S=F3lyom=22?= Organization: none User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.0) Gecko/20020530 X-Accept-Language: hu,en MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: MSDOS/stat() reporting wrong size References: Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com Matthew Mucklo wrote: >Hello, > >I was wondering if anyone knew why MSDOS and stat() therefore return the >wrong file size. fread() appears to finish ahead of the end of the file as >according to stat(). It's reporting less characters read than are actually >in the file (yes, the buffer's big enough). > > > I think the probeem is that you want to read an MSDOS TEXT file containing CR\LF pairs which are converted upon reading to a single LF. Modify this line > fd = fopen(argv[1], "r"); > Open the file in binary mode like fd = fopen(argv[1], "rb");