Xref: utzoo comp.sys.mac.programmer:14987 comp.lang.c:29108 Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!cs.utexas.edu!rutgers!mcnc!decvax.dec.com!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.sys.mac.programmer,comp.lang.c Subject: Re: THINK C4 stdio gotchas Keywords: read, fread, ANSI C Message-ID: <16735@haddock.ima.isc.com> Date: 26 May 90 22:40:49 GMT References: <54861@microsoft.UUCP> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Followup-To: comp.lang.c Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 18 In article <54861@microsoft.UUCP> t-jlee@microsoft.UUCP (Johnny LEE) writes: >THINK C has size_t as an unsigned long and > int read (int fd, char *buf, unsigned int n); >So the number of chars you can request and the number returned as read >won't be equal for values>32767. >In fact, you can request 65535 (or is it 32768?) and if you get >all 65535 chars, your return value will look like an EOF. Actually a read error rather than an EOF. Use of errno can disambiguate this case. >Makes read() kinda limited. Yes. The correct hack is for such implementations to supply a separate function, perhaps named lread(), that does the right thing. Karl W. Z. Heuer (karl@ima.ima.isc.com or harvard!ima!karl), The Walking Lint Followups to comp.lang.c only.