首页  编辑  

字符串和记录的强制转换

Tags: /超级猛料/String.字符串处理/   Date Created:
下面是一个简单的演示:
type
 TEmployee = record
   cNo: array [0..3] of Char;
   cName: array [0..7] of Char;
 end;
 PEmployee = ^TEmployee;
procedure ParseData;
const
 sData = '0001Mosquito';
var
 sNo, sName: string;
begin
 with PEmployee(Pointer((@sData)^))^ do  
 begin
   sNo   := cNo;        // sNo = '0001'
   sName := cName;    // sName = 'Mosquito'
 end
end;