Category : C Source Code
Archive   : C_STRING.ZIP
Filename : MEMREV.C

 
Output of file : MEMREV.C contained in archive : C_STRING.ZIP


/*f File : memrev.c
Author : Richard A. O'Keefe.
Updated: 1 June 1984
Defines: memrev()

memrev(dst, src, len)
moves len bytes from src to dst, in REVERSE order. NUL characters
receive no special treatment, they are moved like the rest. It is
to strrev as memcpy is to strcpy.

Note: this function is perfectly happy to reverse a block into the
same place, memrev(x, x, L) will work.
It will not work for partially overlapping source and destination.
*/

#include "strings.h"

void memrev(dsta, srca, len)
register char *dsta, *srca;
int len;
{
register char *dstz, *srcz;
register int t;

if (len <= 0) return;
srcz = srca+len;
dstz = dsta+len;
while (srcz > srca) {
t = *--srcz;
*--dstz = *srca++;
*dsta++ = t;
}
}



  3 Responses to “Category : C Source Code
Archive   : C_STRING.ZIP
Filename : MEMREV.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/