//方法很多,下边举个例子吧。还可以用union联合进行数据类型的转换,功能更加强大。你这种情况,就按照下边处理吧。
user student
strcpy(student.name,"小明");
student.age=14;
student.sex=TRUE;
buffer = (BYTE*)malloc(sizeof(user));
BYTE *p;
p = (BYTE*)(&student);
for(int i = 0; i
buffer[i] = p[i];
}
buffer[i] = 0;