memcpy的用法实例

zhoulujun

关注

阅读 175

2022-09-16


#include <stdio.h>                                                                                                                         
#include <string.h>

char*
copy_string(char *string)
{
//static char tmp[20];
static char *temp;
memcpy(&temp,&string,10);
//memcpy(temp,string,10);
//memcpy(*temp,*string,10);

return temp;
}

int
main()
{
char *show,*result;
show="haha show";
result="test";
printf("show point to address : %p\n",show);
printf("result point to address : %p\n",result);
result = copy_string(show);
printf("***result string : %s\n",result);
printf("show point to address : %p\n",show);
printf("result point to address : %p\n",result);

return 0;
}

 

精彩评论(0)

0 0 举报