1. 在src所指内存区域复制n个字节到dest所指内存区域;
2. src和dest所指内存区域不能重叠,函数返回指向dest的指针。
3. memccpy()与strncpy()的区别:
(1)strncpy是把n个字符从src中复制到dest中,src和dest地址不能重叠。
(2)memccpy把n个字符从src中复制到dest中,它为内存复制,不管是不是 NULL(空值),通用。
memccpy手册:
MEMCCPY(3) Linux Programmer’s Manual MEMCCPY(3)
NAME
memccpy - copy memory area
//内存拷贝
SYNOPSIS
#include
//包含头文件
void *memccpy(void *dest, const void *src, int c, size_t n);
DESCRIPTION
The memccpy() function copies no more than n bytes from memory area src
to memory area dest, stopping when the character c is found.
//memccpy()函数从源代码内存区域中仅仅拷贝n个字节,送到目的代码的内存区域
中,当参数c建立后停止。
If the memory areas overlap, the results are undefined.
//如果内存中内容重复了,那么结果是不明确的。
RETURN VALUE
The memccpy() function returns a pointer to the next character in dest
after c, or NULL if c was not found in the first n characters of src.
//参数c出现后,memccpy()函数则返回dest中值为c的下一个字符地址,如
果在源代码的n个字符中没有发现c( int c)就为空值。
CONFORMING TO
SVr4, 4.3BSD, POSIX.1-2001.
SEE ALSO
bcopy(3), memcpy(3), memmove(3), strcpy(3), strncpy(3)
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at
//这篇是linux3.22版本手册项目中的一部分。一个项目的描述,还有关于
漏洞信息的报告都会在找到。
GNU 2009-01-13 MEMCCPY(3)
阅读(1483) | 评论(0) | 转发(0) |