Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!mahendo!wlbr!voder!pyramid!ctnews!mitisft!dold From: dold@mitisft.Convergent.COM (Clarence Dold) Newsgroups: comp.lang.c Subject: Re: FILE *fp[]; /* is this possible? */ Message-ID: <1716@mitisft.Convergent.COM> Date: 29 Nov 90 16:00:26 GMT References: <14603@smoke.brl.mil> Organization: Convergent Technologies, San Jose, CA Lines: 20 in article <14603@smoke.brl.mil>, gwyn@smoke.brl.mil (Doug Gwyn) says: > In article <1990Nov28.152146.19560@ssd.kodak.com> weimer@ssd.kodak.com (Gary Weimer) writes: >> if ((fp[i]=fopen(file_name[i],"r+")) <= 0) >> perror("Error opening file"); > Please don't do this; on UNIX, perror() will report the reason for the last > SYSTEM CALL failure, not the reason for failure of a library routine such as Quoth my man page, perror(3c): "... last error encountered during a call to a system or library function..." The most common coding error in this area is to check errno after calling a function, without checking for an error return from the function, resulting in retrieval of some earlier errno, not associated with more recent calls. -- --- Clarence A Dold - dold@tsmiti.Convergent.COM (408) 435-5293 ...pyramid!ctnews!tsmiti!dold FAX (408) 435-3105 P.O.Box 6685, San Jose, CA 95150-6685 MS#10-007