Type1=Record //4+13=17
id :longword;
terminal_id:array[0..12] of char;
end;
在程序中sizeof(type1)=20
Type2=Record //4+4=8
id :longword;
id2 :longword;
end;
在程序中sizeof(type2)=8
Type3=Record //4+13+50=67
id :longword;
terminal_id:array[0..12] of char;
dest:array[0..49] of char;
end;
在程序中szieof(type3)=68
这是为什么?害得我调了几天,老是读数据错位
id :longword;
terminal_id:array[0..12] of char;
end;
在程序中sizeof(type1)=20
Type2=Record //4+4=8
id :longword;
id2 :longword;
end;
在程序中sizeof(type2)=8
Type3=Record //4+13+50=67
id :longword;
terminal_id:array[0..12] of char;
dest:array[0..49] of char;
end;
在程序中szieof(type3)=68
这是为什么?害得我调了几天,老是读数据错位
解决方案 »
- delphi能否判断是否已经登录到域
- listview为什么不显示列头(列标题)?
- 一个摄像头的问题
- 怎样定义两dbgrid一为主二为从
- 给新手的,Delphi的Multi-Tier结构程序开发基础教程(一)
- 用Query连表问题
- 引入Com服务器的类型库的问题
- 出现"Statement expected,but expression of type'TfrxCustomPreview'found",就如何解决?
- 简单问题,请侃侃,关于web ,html
- 30分求知:regedit是怎样控制用户使用的程序??即不允许用户使用!!
- 怎么用xlreport做Excel的模版?我要做一个在浏览报表的时候添加一个能生成Excel模版的功能~
- 简单的问题
id :longword;
terminal_id:array[0..12] of char;
dest:array[0..49] of char;
end;
就不会了.
但只要加上packed就不会(如上)这样有利于结约内存空间,但速度会慢一点.
By default, the values in a structured type are aligned on word or double-word boundaries for faster access. When you declare a structured type, you can include the reserved word packed to implement compressed data storage. For example,type TNumbers = packed array[1..100] of Real;Using packed slows data access and, in the case of a character array, affects type compatibility. For more information, see Memory management.
在未压缩的结构中,单字节类型域从任何地址开始,双字节类型域从偶地址开始,四字节类型从4的倍数地址开始。
例1:
rec= record
a: char;
b: word;
end;
因为word型是双字节,需从偶地址开始存放,所以a后面会有一个字节空间不用,整个结构总共占用4个字节。
例2:
rec= record
a: char;
b: integer;
end;
因为integer型是4字节,需从4倍地址开始存放,所以a后面会有三个字节空间不用,整个结构总共占用8个字节。