Cra*_*008 -4 c c++ linux pointers
假设我有两个变量如下:
typedef struct{
int proc;
int id;
int value;
int last;
} my_struct;
struct my_struct dummy;
int len = 3*sizeof(int);
char my_msg[len];
//Some assignments are done here on those variables
Run Code Online (Sandbox Code Playgroud)
现在,我想dummy通过写上内容来删除内容my_msg.那么以下哪一种更好的方法呢?
memcpy(&dummy, my_msg, size);
Run Code Online (Sandbox Code Playgroud)
要么
&dummy = (my_struct *) my_msg;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1142 次 |
| 最近记录: |