Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site mit-athena.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!mit-athena!jc From: jc@mit-athena.UUCP (John Chambers) Newsgroups: net.lang.c Subject: Re: String help! Message-ID: <104@mit-athena.UUCP> Date: Tue, 5-Mar-85 09:38:19 EST Article-I.D.: mit-athe.104 Posted: Tue Mar 5 09:38:19 1985 Date-Received: Thu, 7-Mar-85 05:20:49 EST References: <7014@watdaisy.UUCP> Organization: MIT Project Athena Lines: 21 Let's see, reasons for returning pointers to constant strings...? Several times in the past couple years I have written routines that end with code something like: ... fail: /* Jump here for disasters*/ errno = EGLORCH; fprintf(stderr,"***foo() FAILED.\n"); return("???FOO???"); } This is for a function that normally returns a pointer to a string of characters. The idea is that if the caller doesn't notice the failure and tries to use the return value, the program won't just bomb inexplicably (as it might do if you return NULL); it will have a character string that will tend to stand out wherever it pops up later. In this case, it doesn't much matter if the caller changes the string, since it is basically a string of garbage anyway. Anyone got any more examples? John Chambers