memccpy(), _fmemccpy()

copy bytes until a given character is found


#include <string.h>
void *memccpy( void *dest, 
               const void *src,
               int c,
               size_t cnt );
void __far *_fmemccpy( void __far *dest,
                       const void __far *src,
                       int c,
                       size_t cnt );


The memccpy() function copies bytes from src to dest, up to and including the first occurrence of the character c, or until cnt bytes have been copied, whichever comes first.

The _fmemccpy() function is a data-model-independent form of the memcppy() function. It accepts far pointer arguments, and returns a far pointer. It is most useful in mixed memory model applications.


A pointer to the byte in dest following the character c, if one is found and copied, otherwise NULL.


#include <stdio.h>
#include <string.h>

char *msg = "This is the string: not copied";

void main()
    char buffer[80];

    memset( buffer, '\0', 80 );
    memccpy( buffer, msg, ':', 80 );
    printf( "%s\n", buffer );

produces the output:

This is the string:



Interrupt handler Yes
Signal handler Yes
Thread Yes

See also:

memcpy(), memmove(), memset()