From: Radical DOT NetSurfer AT delorie DOT com Newsgroups: comp.os.msdos.djgpp Subject: Re: Benchmark Testing Date: Thu, 27 Sep 2001 16:22:02 -0400 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: <9osdbt$r8k$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> <9ov09c$gig$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> <4634-Thu27Sep2001154412+0300-eliz AT is DOT elta DOT co DOT il> X-Newsreader: Forte Agent 1.8/32.548 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: newsabuse AT supernews DOT com Lines: 49 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com /* ** STRREV.C - reverse a string in place ** ** public domain by Bob Stout */ char *strrev(char *str) { char *p1, *p2; if (! str || ! *str) return str; for (p1 = str, p2 = str + strlen(str) - 1; p2 > p1; ++p1, --p2) { *p1 ^= *p2; *p2 ^= *p1; *p1 ^= *p2; } return str; } and how does the above code compare to, whats below, in terms of CPU time, and memory-access, etc? /* ======================= */ /* reverse string in place */ char *strrev(char *string) { char *last, temp; last = string + strlen(string); /* points to '\0' */ while (last-- > string) { temp = *string; *string++ = *last; *last = temp; } return (char*)string; } /* strrev */ strrev(), according to every compiler I've seen that supports it, always returns a pointer to the modified string. On Thu, 27 Sep 2001 15:44:13 +0200, "Eli Zaretskii" wrote: >> From: Radical DOT NetSurfer AT delorie DOT com >> Newsgroups: comp.os.msdos.djgpp >> Date: Thu, 27 Sep 2001 09:06:49 -0400 >> >> PLEASE libc.a people, __add__ strrev() its been missing for far too >> long. Thanks. > >It's on my TODO.