man(1) Manual page archive


     MEMORY(3)                                               MEMORY(3)

     NAME
          memccpy, memchr, memcmp, memcpy, memmove, memset - memory
          operations

     SYNOPSIS
          char *memccpy(s1, s2, c, n)
          char *s1, *s2;
          int c, n;

          char *memchr(s, c, n)
          char *s;
          int c, n;

          int memcmp(s1, s2, n)
          char *s1, *s2;
          int n;

          char *memcpy(s1, s2, n)
          char *s1, *s2;
          int n;

          char *memmove(s1, s2, n)
          char *s1, *s2;
          int n;

          char *memset(s, c, n)
          char *s;
          int c, n;

     DESCRIPTION
          These functions operate efficiently on memory areas (arrays
          of characters bounded by a count, not terminated by a null
          character).  They do not check for the overflow of any
          receiving memory area.

          Memccpy copies characters from memory area s2 into s1, stop-
          ping after the first occurrence of character c has been
          copied, or after n characters have been copied, whichever
          comes first.  It returns a pointer to the character after
          the copy of c in s1, or zero if c was not found in the first
          n characters of s2.

          Memchr returns a pointer to the first occurrence of charac-
          ter c in the first n characters of memory area s, or zero if
          c does not occur.

          Memcmp compares its arguments, looking at the first n char-
          acters only, and returns an integer less than, equal to, or
          greater than 0, according as s1 is lexicographically less
          than, equal to, or greater than s2.

     MEMORY(3)                                               MEMORY(3)

          Memcpy copies n characters from memory area s2 to s1. It
          returns s1.

          Memmove is the same as memcpy, except it is guaranteed to
          handle overlapping strings as if the move had been made to a
          temporary and then to the destination.

          Memset sets the first n characters in memory area s to the
          value of character c. It returns s.

     SEE ALSO
          string(3)

     BUGS
          Memcmp uses native character comparison, which is signed on
          some machines, unsigned on others; thus the sign of the
          value returned when a character has its high-order bit set
          is implementation-dependent.
          Thanks to ANSI X3J11 for the memcpy/memmove distinction.