From: P DOT J DOT Kersten AT dia DOT eur DOT nl (P.J. Kersten) Subject: Re: fread fails when fopen is used without "rb" 13 Mar 1998 23:32:31 -0800 Message-ID: <3508EC7A.A3B99CE8.cygnus.gnu-win32@dia.eur.nl> References: <199803121330 DOT HAA17235 AT chad DOT ccrl DOT mot DOT com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: cutts AT ccrl DOT mot DOT com Cc: gnu-win32 AT cygnus DOT com Kevin Cutts wrote: > > I made a mistake and opened a binary file using fopen("file","r"). Note that > I forgot to open it with "rb". When I read the file, I could only read part > of the file: the read only suceeded for 2081 bytes of the 345K! Believing > that I had made a coding mistake, I tried 'wc'. It agreed with my code: they > both 'think' the file has 2081 bytes. However emacs and ls both realize the > file is much larger. (When I used a truly ascii file, the size worked > correctly. The code hack does work correctly under the Metrowerks compiler.) > > Does this seem like the correct behaviour? I can't trust wc because it > obviously opens as text. I looked in the faq without seeing anything that > suggests this operation. In this case the failure was the best thing that > could have happened because I discovered that the legacy unix code needs > some work around the binary/text problems. > [snip] Just a guess: byte 2082 is ^D? HTH, -- Pieter J. Kersten; Erasmus Universiteit Rotterdam, dept. DI&A/S&N, WH2-10, B. Oudlaan 50, 3062 PA Rotterdam, The Netherlands; Voice: +31-10-4082599; Fax: +31-10-4527236 - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".