typedef struct __STUDENT
{
int iAge;
int iYear;
int iMonth;
}STUDENT,*PSTUDENT;
方法一:结构体-->字符串数组
PSTUDENT st = NULL;
st = (PSTUDENT)new char[12];
memset(st,0,12);
st->iAge = 12;
st->iMonth = 14;
st->iYear = 100;
CHAR szBuf[13] = {0};
memcpy(szBuf,st,12);
delete st;
st = NULL;
方法二:结构体--->字符串数组
STUDENT st;
st.iAge = 12;
st.IMonth = 12;
st.iYear = 1990;
CHAR szBuf[13] = {0};
memcpy(szBuf,&st,12);
方法一:字符串数组--->结构体
PSTUDENT st1 = NULL;
st1 = (PSTUDENT)szBuf;
CString str;
str.Format("%d %d %d",st1->iAge,st1->iMonth,st1->iYear);
MessageBox(str);
|