delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/27/04:02:42

From: "Gerhard W. Gruber" <g DOT gruber AT sis DOT co DOT at>
Newsgroups: comp.os.msdos.djgpp
Subject: Problem with read()
Date: Mon, 27 Apr 1998 09:59:39 +0200
Organization: S.I.S. IT
Lines: 30
Message-ID: <35443AEB.7115C264@sis.co.at>
NNTP-Posting-Host: 192.56.14.75
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I'm not sure if this is an error in the standard library or if the
behaviour in this case is not exactly defined.

I'm trying to read a file into memory. My buffer to read in is 4096 bytes
long and the file is 10 bytes long.

I seek to position 5 of the file and call read with read(hdl, buffer,
4096). The result of read should be the number of bytes actually read or -1
if an error occured. In this case it should return 5 bytes, because the
remainder of the file is 5 bytes, but I get -1.

Is this an error or is this behaviour correct? I never encountered this
problem with other compilers and I thought that the standard says that
reading beyond the EOF is not an error condition.
-- 

Bye,
   Gerhard

Powered by Linux 2.0 Expert Experimental Programmer :)

email: sparhawk AT eunet DOT at
       g DOT gruber AT sis DOT co DOT at

Harrison's postulate:  
For every action, there is an equal and opposite criticism.
------------------------------------------------------------
Politically Correct DOS: Ask any key if it wants to be hit.
Politically Correct, the perfect oxymoron.
Why be Politically Correct, when you can be right?

- Raw text -


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