home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntlib25.zoo / strrev.c < prev    next >
C/C++ Source or Header  |  1992-09-05  |  423b  |  25 lines

  1. /* from Dale Schumacher's dLibs library */
  2.  
  3. /* if you chage the behaviour so that it does not reverse in-place
  4.  * please change mktemp.c too (it assumes rev is in-place)
  5.  */
  6.  
  7. char *strrev(string)
  8.     char *string;
  9.     {
  10.     register char *p = string, *q, c;
  11.  
  12.     if(*(q = p))        /* non-empty string? */
  13.         {
  14.         while(*++q)
  15.             ;
  16.         while(--q > p)
  17.             {
  18.             c = *q;
  19.             *q = *p;
  20.             *p++ = c;
  21.             }
  22.         }
  23.     return(string);
  24.     }
  25.