delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/09/04/17:06:47

From: Ian AT kiwiplan DOT co DOT nz (Ian Collins)
Subject: Reading a ^Z
4 Sep 1997 17:06:47 -0700 :
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <07551A47EAD6D01186430060B025C6F40A6CA8.cygnus.gnu-win32@ntserver.kiwiplan2.co.nz>
Mime-Version: 1.0
Original-To: "'Gnu win32 mailer'" <gnu-win32 AT cygnus DOT com>
X-Priority: 3
X-Mailer: Internet Mail Service (5.0.1457.3)
Original-Sender: owner-gnu-win32 AT cygnus DOT com

Please help someone!

I am sure this has come up before (probably before I joined).
I am reading a binary file. The file is fopened with O_RDONLY.
When doing the read, I am using,

n = fread((void *) buffer, (size_t) sizeof(char), (size_t)
numrecs*reclen, ifd);

where numrecs and reclen are the number of records in the file each of
length reclen.

If there is a control-Z (^Z) in the file, the fread will read up to the
^Z and the rest of the buffer is filled with NULLS.
Now I know, in the distant past, DOS files were terminated by a ^Z, but
surely there is a workaround to this.
I am using b18 with Sergeys latest cygwin.dll.
-
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".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019