From: Erik Max Francis Newsgroups: comp.os.msdos.djgpp,comp.lang.c++ Subject: Re: Reading binary files Date: Fri, 20 Jun 1997 09:11:35 -0700 Organization: Alcyone Systems Lines: 21 Message-ID: <33AAABB7.1E87416B@alcyone.com> References: <33a13a3a DOT 2140316 AT supernews DOT scsn DOT net> NNTP-Posting-Host: newton.alcyone.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Chris wrote: > What I am doing is reading in numbers as shorts and need a function > that can do that with a binary file and stop at the EOF. How is this > best accomplished. I'm surprised this question is asked so often, since every C book I've seen goes over this point in detail. If you want to open a file in binary, then you need to open it as such. You do this by using mode "rb" in the call to fopen: file = fopen(filename, "rb"); -- Erik Max Francis, &tSftDotIotE / email / max AT alcyone DOT com Alcyone Systems / web / http://www.alcyone.com/max/ San Jose, California, United States / icbm / 37 20 07 N 121 53 38 W \ "Covenants without the sword / are but words." / Camden