error
memcpy(wrmsg.buf,msg,sizeof(char_msg_t));语法错误
Correct (all three ways of writing are fine)
//结构体拷到数组
memcpy(wrmsg.buf,(char*)&msg,sizeof(char_msg_t));强转与不强转是一致的
memcpy(&wrmsg.buf,&msg,sizeof(char_msg_t));
memcpy(wrmsg.buf,&msg,sizeof(char_msg_t));
After the structure is copied to the array, the printed array may be empty or garbled. Don't panic at this time, you can convert the array to a structure for verification
//数组拷到字符串
char_msg_t getmsg;
memcpy(&getmsg,wrmsg.buf,sizeof(char_msg_t));