[comp.lang.c] Why not "const char *strerror

rk9005@cca.ucsf.edu (Roland McGrath) (01/25/88)

Well, let's try this again ...

Why doesn't the standard declare strerror as
	const char *strerror(int errnum);
and similarly for all functions that return pointers to
data the user is not supposed to modify?

With a compiler that puts string literals in read-only memory,
with sys_errlist (or whatever) defined as:
	const char *sys_errlist[] = { "Error 0", ... };
if the user tries to modify the string returned by strerror,
it might cause some illegal instruction fault or something.

Is there any reason why it is declared as "char *"??
-- 
		Roland McGrath
UUCP: 			...!ucbvax!lbl-rtsg.arpa!roland
ARPA:	 		roland@rtsg.lbl.gov