Compartir a través de


_memccpy

Copies characters from a buffer.

void*_memccpy(void*dest,constvoid*src,intc**,unsignedintcount);**

Routine Required Header Compatibility
_memccpy <memory.h> or <string.h> Win 95, Win NT

For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version

Return Value

If the character c is copied, _memccpy returns a pointer to the byte in dest that immediately follows the character. If c is not copied, it returns NULL.

Parameters

dest

Pointer to destination

src

Pointer to source

c

Last character to copy

count

Number of characters

Remarks

The _memccpy function copies 0 or more bytes of src to dest, halting when the character c has been copied or when count bytes have been copied, whichever comes first.

Example

/* MEMCCPY.C */

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

char string1[60] = "The quick brown dog jumps over the lazy fox";

void main( void )
{
   char buffer[61];
   char *pdest;

   printf( "Function:\t_memccpy 60 characters or to character 's'\n" );
   printf( "Source:\t\t%s\n", string1 );
   pdest = _memccpy( buffer, string1, 's', 60 );
   *pdest = '\0';
   printf( "Result:\t\t%s\n", buffer );
   printf( "Length:\t\t%d characters\n\n", strlen( buffer ) );
}

Output

Function:   _memccpy 60 characters or to character 's'
Source:      The quick brown dog jumps over the lazy fox
Result:      The quick brown dog jumps
Length:      25 characters

Buffer Manipulation Routines

See Also   memchr, memcmp, memcpy, memset