Copy characters from a buffer.
#include <memory.h> | Required only for function declarations | |
#include <string.h> | Use either STRING.H or MEMORY.H |
void *_memccpy( void *dest, void *src, int c, unsigned int count );
void __far * __far _fmemccpy( void __far *dest, void __far *src, int c, unsigned int count );
dest | Pointer to destination | |
src | Pointer to source | |
c | Last character to copy | |
count | Number of characters |
The _memccpy and _fmemccpy functions copy 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.
The _fmemccpy function is a model-independent (large-model) form of the _memccpy function. It can be called from any point in any program.
If the character c is copied, _memccpy or _fmemccpy returns a pointer (or far pointer) to the byte in dest that immediately follows the character. If c is not copied, both return NULL.
_memccpy
Standards:UNIX
16-Bit:DOS, QWIN, WIN, WIN DLL
32-Bit:DOS32X
Use _memccpy for compatibility with ANSI naming conventions of non-ANSI functions. Use memccpy and link with OLDNAMES.LIB for UNIX compatibility._fmemccpy
Standards:None
16-Bit:DOS, QWIN, WIN, WIN DLL
32-Bit:None
memchr, memcmp, memcpy, memset
/* 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 ) );
}
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