Xref: utzoo comp.sys.mac.programmer:14966 comp.lang.c:29079 Path: utzoo!attcan!uunet!microsoft!t-jlee From: t-jlee@microsoft.UUCP (Johnny LEE) Newsgroups: comp.sys.mac.programmer,comp.lang.c Subject: THINK C4 stdio gotchas Keywords: read, fread, ANSI C Message-ID: <54861@microsoft.UUCP> Date: 25 May 90 04:16:43 GMT Reply-To: t-jlee@microsoft.UUCP (Johnny LEE) Organization: Microsoft Corp., Redmond WA Lines: 24 While porting GNU Diff to the Mac in my spare time, I came upon an anomaly in the stdio and unix libraries for THINK C4. In K&R 2Ed, fread and read are defined as: size_t fread(void *ptr, size_t size, size_t nobj, FILE *stream); int read (int fd, char *buf, int n); 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. Makes read() kinda limited. 'Tis fun porting stuff which assumes int==long. Fun... WOW. Standard Disclaimer. Johnny Lee t-jlee@microsoft.UUCP ...!uunet!microsoft!t-jlee