strcpy是拷贝字符串,以\0为标志结束(即一旦遇到数据值为0的内存地址拷贝过程即停止)
strcpy的原型为
char *strcpy(char *dest, const char *src)
而memcpy是给定来源和目标后,拷贝指定大小n的内存数据,而不管拷贝的内容是什么(不仅限于字符)
memcpy的原型为
void *memcpy(void *dest, const void *src, size_t n);
举例:
typedef struct st_response
{
int nResponseLength;
unsigned char responseContent[MAX_RESPONSE_LENGTH];
time_t tTimeStamp;
}RESPONSE;
unsigned char src[1024]={0x09,0x09,0x09,0x05,0x10,0x00,0xc1,0x48,0x01,0x01,0x3c};
memset(pResponse.responseContent,'\0',1024);
memcpy(pResponse.responseContent,src,1024);
阅读(993) | 评论(0) | 转发(0) |