D
ddzhouqian
Unregistered / Unconfirmed
GUEST, unregistred user!
//delphi
procedure TForm1.Button1Click(Sender: TObject)
type TRecord1=record
a1:byte
d1:Cardinal
end
type TRecord2=packed record
a1:byte
d1:Cardinal
end
begin
showmessage(IntToStr(SizeOf(TRecord1)));//输出值为8
showmessage(IntToStr(SizeOf(TRecord2)));//输出值为5
end
//vc
typedef struct tagTStruct1
{
unsigned char a1
unsigned int d1
}TStruct1,*LStruct1
void Cdialog1::OnBnClickedOk()
{
int value=0
char value1[100]
CString value2
value2=""
itoa(sizeof(TStruct1),value1,10)
value2.Format("struct is %s",value1)
AfxMessageBox(value2)
//输出值为8
}
以上代码均调试过了,想请问vc中为什么取出的占用大小也是8啊,这样起不是很占用资源吗?(对比与delphi packed record类型),本人对vc不太了解,也没用过,只是最近需要看些代码,才弄了下,只是本着相互学习的态度,请大家场所语言,分不够我会加的
procedure TForm1.Button1Click(Sender: TObject)
type TRecord1=record
a1:byte
d1:Cardinal
end
type TRecord2=packed record
a1:byte
d1:Cardinal
end
begin
showmessage(IntToStr(SizeOf(TRecord1)));//输出值为8
showmessage(IntToStr(SizeOf(TRecord2)));//输出值为5
end
//vc
typedef struct tagTStruct1
{
unsigned char a1
unsigned int d1
}TStruct1,*LStruct1
void Cdialog1::OnBnClickedOk()
{
int value=0
char value1[100]
CString value2
value2=""
itoa(sizeof(TStruct1),value1,10)
value2.Format("struct is %s",value1)
AfxMessageBox(value2)
//输出值为8
}
以上代码均调试过了,想请问vc中为什么取出的占用大小也是8啊,这样起不是很占用资源吗?(对比与delphi packed record类型),本人对vc不太了解,也没用过,只是最近需要看些代码,才弄了下,只是本着相互学习的态度,请大家场所语言,分不够我会加的