From: ams AT ludd DOT luth DOT se (Martin Str|mberg) Newsgroups: comp.os.msdos.djgpp Subject: Re: Problem reading DOS binary files Date: 6 Jan 2000 00:13:20 GMT Organization: University of Lulea, Sweden Lines: 19 Message-ID: <850mn0$23u$1@news.luth.se> References: <84ddkm$r3i$1 AT plato DOT harvard DOT edu> NNTP-Posting-Host: queeg.ludd.luth.se X-Trace: news.luth.se 947117600 2174 130.240.16.109 (6 Jan 2000 00:13:20 GMT) X-Complaints-To: abuse AT luth DOT se NNTP-Posting-Date: 6 Jan 2000 00:13:20 GMT X-Newsreader: TIN [UNIX 1.3 950824BETA PL0] To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Greg Wellenius (gwelleni AT hsph DOT harvard DOT edu) wrote: : I'm having problems reading binary files using fstream's 'read' function. : : In the following loop, I read two bytes, skip ahead 6 bytes, and so on until : I reach an EOF. The loop exits long before the true end of file is reached. : : ------------------------- : short tmpdata; : : // Open file read only : fstream dataFile.open( fileName, ios::in ); I'm not a C++ programmer but shouldn't you open a binary file in binary mode? Right, MartinS