Skip to content

Latest commit

 

History

History
139 lines (116 loc) · 3.34 KB

File metadata and controls

139 lines (116 loc) · 3.34 KB
title _memccpy | Microsoft Docs
ms.custom
ms.date 11/04/2016
ms.reviewer
ms.suite
ms.technology
cpp-standard-libraries
ms.tgt_pltfrm
ms.topic article
apiname
_memccpy
apilocation
msvcrt.dll
msvcr80.dll
msvcr90.dll
msvcr100.dll
msvcr100_clr0400.dll
msvcr110.dll
msvcr110_clr0400.dll
msvcr120.dll
msvcr120_clr0400.dll
ucrtbase.dll
api-ms-win-crt-string-l1-1-0.dll
apitype DLLExport
f1_keywords
_memccpy
dev_langs
C++
helpviewer_keywords
_memccpy function
memccpy function
ms.assetid 9a2337df-6e85-4eba-b247-dd0532f45ddb
caps.latest.revision 12
author corob-msft
ms.author corob
manager ghogen
translation.priority.ht
cs-cz
de-de
es-es
fr-fr
it-it
ja-jp
ko-kr
pl-pl
pt-br
ru-ru
tr-tr
zh-cn
zh-tw

_memccpy

Copies characters from a buffer.

Syntax

  
      void *_memccpy(  
   void *dest,  
   const void *src,  
   int c,  
   size_t count   
);  

Parameters

dest
Pointer to the destination.

src
Pointer to the source.

c
Last character to copy.

count
Number of characters.

Return Value

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

Remarks

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

Security Note Make sure that the destination buffer is the same size or larger than the source buffer. For more information, see Avoiding Buffer Overruns.

Requirements

Routine Required header
_memccpy <memory.h> or <string.h>

For more compatibility information, see Compatibility in the Introduction.

Libraries

All versions of the C run-time libraries.

Example

// crt_memccpy.c  
  
#include <memory.h>  
#include <stdio.h>  
#include <string.h>  
  
char string1[60] = "The quick brown dog jumps over the lazy fox";  
  
int main( void )  
{  
   char buffer[61];  
   char *pdest;  
  
   printf( "Function: _memccpy 60 characters or to character 's'\n" );  
   printf( "Source: %s\n", string1 );  
   pdest = _memccpy( buffer, string1, 's', 60 );  
   *pdest = '\0';  
   printf( "Result: %s\n", buffer );  
   printf( "Length: %d characters\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  

See Also

Buffer Manipulation
memchr, wmemchr
memcmp, wmemcmp
memcpy, wmemcpy
memset, wmemset