Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo C - <b>memccpy() copy characters from buffer</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
memccpy()                Copy Characters from Buffer

 #include   <memory.h>                   Required for declarations only
 #include   <string.h>                   Use either string.h or memory.h

 char       *memccpy(dest,source,ch,cnt);
 char       *dest;                       Pointer to destination
 char       *source;                     Pointer to source
 int        ch;                          Last character to copy
 unsigned   cnt;                         Maximum number of characters to copy

    memccpy() copies characters from 'source' to 'dest', up to and
    including the first occurrence of 'ch', or until a maximum of 'cnt'
    bytes have been copied, whichever occurs first.

    Returns:    If 'ch' has been found and copied, a pointer to the byte
                after 'ch' in 'dest' is returned.  NULL  is returned if
                'ch' was not copied.

      Notes:    Use memcpy() to copy 'cnt' bytes from one buffer to
                another without checking for a character.

                Buffers are arrays of characters and are usually not
                terminated with a null character ('\0').  The
                buffer-manipulation routines always have a length or
                count argument.

  -------------------------------- Example ---------------------------------

    The following statement copies characters from 'from_buffer' into
    'to_buffer' until the "@" character or 128 bytes are copied,
    whichever happens first.

         #include <memory.h.

         char to_buffer[128];
         char from_buffer[128];
         char *bufptr;

         main()
         {
             bufptr = memccpy(to_buffer, from_buffer, '@', 128);
         }

See Also: memchr() memcmp() memcpy() memset()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson