home *** CD-ROM | disk | FTP | other *** search
/ Boston 2 / boston-2.iso / DOS / PROGRAM / C / BPLUS / MEMMOVE.C < prev   
C/C++ Source or Header  |  1993-12-01  |  771b  |  32 lines

  1. /*****************************************************************
  2.  |  memmove - move in memory with attention to order and overlap
  3.  |----------------------------------------------------------------
  4.  |  Arguments:
  5.  |   1) destination: char *
  6.  |   2) source: char *
  7.  |   3) length: int
  8.  |  Returns: none
  9.  ****************************************************************/
  10.  
  11. void memmove (to, from, length)
  12.     char *to, *from;
  13.     int  length;
  14. {
  15.     register char *TO, *FROM;
  16.  
  17.     if (to < from) {
  18.     /* move left to right */
  19.     TO = to;
  20.     FROM = from;
  21.     while (length--)
  22.         *(TO++) = *(FROM++);
  23.     }
  24.     else {
  25.     /* move right to left */
  26.     TO = to + length - 1;
  27.     FROM = from + length - 1;
  28.     while (length--)
  29.         *(TO--) = *(FROM--);
  30.     }
  31. }
  32.