Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: C file access question Message-ID: <3757@goanna.cs.rmit.oz.au> Date: 14 Sep 90 07:39:22 GMT References: <28@screamer.csee.usf.edu> Distribution: comp.lang.c Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 27 In article <28@screamer.csee.usf.edu>, stelmack@screamer.csee.usf.edu (Gregory M. Stelmack) writes: > I've got some code I'm writing for ANSI file access [under SunOS 4.0.3] > db = fopen("dd.data","rb+"); /* db is checked to make sure file opened */ ^^^ RTFM. The SunOS 4.0.3 C compiler is _not_ ANSI compliant and Sun have never pretended that it is. If you read the manual page for fopen() [- if you don't know how, here's all it takes: man fopen ] the manual page lists all the mode strings that Sun's fopen() understands, and fb+ isn't one of them. This "b" stuff is a kluge to work around the PC convention of using two characters to end a line (ASCII has a "record separator character", I've never understood why people didn't use that). UNIX doesn't need it. The simplest fix should be static char BinaryReadWriteMode[] = #ifdef unix "r+"; #else "rb+"; #endif ... db = fopen("dd.data", BinaryReadWriteMode); -- Heuer's Law: Any feature is a bug unless it can be turned off.