C语言中memcopy函数功能及用法

    技术2022-05-12  11

    函数名: memcpy 功  能: 从源source中拷贝n个字节到目标destin中 用  法: void *memcpy(void *destin, void *source, unsigned n); 程序例:

    #include <stdio.h> #include <string.h> int main(void) {    char src[] = "******************************";    char dest[] = "abcdefghijlkmnopqrstuvwxyz0123456709";    char *ptr;    printf("destination before memcpy: %s/n", dest);    ptr = memcpy(dest, src, strlen(src));    /*****目标destin,源source,拷贝长度*****/   if (ptr)                                                   /******ptr=1*****/      printf("destination after memcpy:  %s/n", dest);    else       printf("memcpy failed/n");    return 0; }


    最新回复(0)