strerror() (was: perror)

Maarten Litmaath maart at cs.vu.nl
Wed Jul 4 01:16:41 AEST 1990


In article <MEISSNER.90Jul3102104 at osf.osf.org>,
	meissner at osf.org (Michael Meissner) writes:
)...
)char *
)strerror(e)
){
)  extern int	errno;
)  extern int	sys_nerr;
)  extern char	*sys_errlist[];
)
)  if (e < 0 || e >= sys_nerr)
)      return "Unknown error";
)
)  return sys_errlist[e];
)}
)...

Always give as much information as possible!
--------------------cut here--------------------
char	*strerror()
{
	extern	int	errno, sys_nerr;
	extern	char	*sys_errlist[];
	static	char	buf[32];

	if ((unsigned) errno < sys_nerr)
		return sys_errlist[errno];
	sprintf(buf, "Unknown error %d", errno);
	return buf;
}
--
 "and with a sudden plop it lands on usenet.  what is it? omigosh, it must[...]
   be a new user! quick kill it before it multiplies!"      (Loren J. Miller)



More information about the Comp.lang.c mailing list