delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/05/24/08:30:16

From: Waldemar Schultz <schultz AT ma DOT tum DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: WANTED: strrev() where is it???
Date: Wed, 24 May 2000 14:18:25 +0200
Organization: [posted via] Leibniz-Rechenzentrum, Muenchen (Germany)
Lines: 47
Message-ID: <392BC891.B8A0D8@ma.tum.de>
References: <8gfcsp$due$1 AT nnrp1 DOT deja DOT com>
NNTP-Posting-Host: pcritter10.mathematik.tu-muenchen.de
Mime-Version: 1.0
X-Trace: wsc10.lrz-muenchen.de 959170804 25885 131.159.69.74 (24 May 2000 12:20:04 GMT)
X-Complaints-To: news AT lrz-muenchen DOT de
NNTP-Posting-Date: 24 May 2000 12:20:04 GMT
X-Mailer: Mozilla 4.6 [de] (Win98; I)
X-Accept-Language: de,en,en-US
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

RadSurfer schrieb:
> 
> Porting a program from Borland ....
> it uses   strrev()  function....
> of all the string functions in DJGPP...
> THAT one is not there  :(
> 
> Is it under a different name?
> 
> Do I have to resort to a routine to emulate  strrev()  ?

#include <string.h>

#if defined(__cplusplus) && __cplusplus
 extern "C" {
#endif
char *strrev(char *str)
{
char *p1=NULL,*p2=NULL;
  if(! str || ! *str)
   return str;
  for(p1=str,p2=str+strlen(str)-1;p2>p1;*p1^=*p2,*p2^=*p1,*(p1++)^=*(p2--));
  return str;
}
#if defined(__cplusplus) && __cplusplus
            }
#endif

#ifdef TEST
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
 while (--argc)
 {
  printf("\"%s\" <==> ", *++argv);
  printf("\"%s\"\n", strrev(*argv));
 }
 return EXIT_SUCCESS;
}
#endif /* TEST */

-- 
 Gruss Waldemar Schultz.
 Technische Universität München, Zentrum Mathematik M1, D 80290 München
 Tel: +49 (0)89 2892 8226        FAX: +49 (0)89 2892 8228

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019