Linux 常用函数——memcpy函数

来源:互联网 发布:java mvc框架理解 编辑:程序博客网 时间:2024/05/20 14:17
/*Linux 常用函数——memcpy函数原型:extern void *memcpy(void *dest, void *src, unsigned int count);用法:#include <string.h>功能:由src所指内存区域复制count个字节到dest所指内存区域。说明:src和dest所指内存区域不能重叠,函数返回指向dest的指针。*///exzample: #include <stdio.h>#include <stdlib.h>#include <string.h>struct node{    int a;    struct node* next;}node;typedef struct node* pnode;int main(){    struct node *p;    p = (struct node*)malloc(sizeof(struct node));    p->a = 1;    p->next = NULL;    struct node *q;    q = (struct node*)malloc(sizeof(struct node));    memcpy(q,p,sizeof(struct node));    printf("%d",q->a);    return 0;    }

0 0
原创粉丝点击