memccpy() -- string字符串的拷贝

相关函数: 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);
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值