Delphi中的数据类型

类型      名称   字节数       取值范围
Integer   整型     4     -2147483648-2147483647
Cardinal  实数型   4         0-4294967295
longword  长字型   4         0-4294967295 

smallInt  小整型   2     -32768-32767
Word   实数小整型  2     0-65535

shortInt  短整型   1     -128-127
Byte    实数短整型 1     0-255

Boolean  逻辑型    1     False(假)0/True(真)1

string   文本型   255个字符 可以指定长短 比如:var mystring:string[100] 占100个字节的空间

数组 定义数组
a:array[0..5]of Byte;
名字a 长度16个字节 内存中是 00 01 02 03 04 05

b:array[0..5]of Cardinal;
名字b 长度16个字节 内存中是 00 00 00 00 01 01 01 01 02 02 02 02 03 03 03 03 04 04 04 04 05 05 05 05


记录类型
 type
   student=record //记录类型的名称
   stuid:Integer; //学生ID
   name:string;   //名字
   age:Byte;      //年龄
 end;

showmessage //信息框(不如用微软的API:messagebox)
inttostr    //整数到文本

下面是源码

implementation
 type
   student=record //记录类型的名称
   stuid:Integer;
   name:string;
   age:Byte;
 end;


{$R *.dfm}

procedure TForm1.anniu(Sender: TObject);
var i:Byte;
    a:array[0..5]of Byte;
    b:array[0..5]of Cardinal;
    std:student;
begin
    i:=251;
    a[0]:=1;
    b[0]:=4294967295;
    ShowMessage(IntToStr(i));
    ShowMessage(IntToStr(a[0]));
    ShowMessage(IntToStr(b[0]));
    std.stuid:=24 ;
    std.name:='lilian';
    std.age:=12;
    ShowMessage(IntToStr(std.stuid));
    ShowMessage(std.name);
    ShowMessage(IntToStr(std.age));
end;

end.
原文地址:https://www.cnblogs.com/qq32175822/p/3139247.html