相關函數: bcopy(), memcpy(), memmove(), strcpy(), strncpy()
表頭文件: #include <string.h>
定義函數: void *memccpy(void *dest, const void *src, int c, size_t n);
函數說明: memccpy()用來拷貝src所指的內存內容前n個字節到dest所指的地址上。與memcpy()不同的是,memccpy()如果在src中遇到某個特定值(int c)立即停止復制。
返回值: 返回指向dest中值為c的下一個字節指針。返回值為0表示在src所指內存前n個字節中沒有值為c的字節。
void * memccpy (void *restrict to, const void *restrict from, int c, size t [Function]
size)
This function copies no more than size bytes from from to to, stopping if a byte
matching c is found. The return value is a pointer into to one byte past where c was
copied, or a null pointer if no byte matching c appeared in the first size bytes of from.
#include <string.h>
#include <stdio.h>
int main()
{
char a[] = "string[a]";
char b[] = "string(b)";
memccpy(a, b, 'b', sizeof(b)); //a[] = "string(b]"
printf("memccpy():%s\n", a);
}