Date: Sat, 29 Sep 2001 10:56:03 +0200 From: "Eli Zaretskii" Sender: halo1 AT zahav DOT net DOT il To: djgpp AT delorie DOT com Message-Id: <2110-Sat29Sep2001105602+0300-eliz@is.elta.co.il> X-Mailer: Emacs 20.6 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.9 In-reply-to: (Radical DOT NetSurfer AT delorie DOT com) Subject: Re: Please add strrev proposal References: <3BB50884 DOT 347A4384 AT yahoo DOT com> <3BB55487 DOT CC4407ED AT worldnet DOT att DOT net> Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > From: Radical DOT NetSurfer AT delorie DOT com > Newsgroups: comp.os.msdos.djgpp > Date: Sat, 29 Sep 2001 02:13:50 -0400 > > OUTCH! you believe this behavior is correct, too? Of course, it's correct! That's how a C compiler is supposed to work. _Any_ C compiler, including Borland's. Namely, all the arguments of a function are computed _before_ the function is called. Since one of the arguments to printf calls strrev, strrev is called before printf is called. Since the value returned by strrev is the same as its argument (both are pointers to the same storage), if you want to print the original and the reversed strings, you need to do this: printf ("Orig: %s\n", s); printf ("Rev: %s\n", strrev (s)); That is, you need to print the original string _before_ you write any expression which includes a call to strrev. > psst: that returns the last static value of a func, in this > case, whatever the last string that was "reversed" That's not how Borland's documentation defines strrev. It explicitly says: "...strrev returns its argument `str'". The implementation you suggested contradicts this specification.