zoukankan      html  css  js  c++  java
  • Delphi结构体数组指针的问题

    //这段代码在Delphi 2007和delphi 7下是可以执行的,所以正确使用结构体数组和指针应该是这样的,已验证
    
    unit
    Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Memo1: TMemo; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); type TMyType = record S: String; I: Integer; end; TMyArray = array of TMyType; PMyArray = ^TMyArray; var MyArray: PMyArray; i:integer; AList:TStrings; begin try new(MyArray); AList:=TStringList.Create; SetLength(MyArray^, 50000); for i:=0 to 49999 do begin MyArray^[i].S :='中山'+inttostr(i); myArray^[i].I :=i; AList.Add(MyArray^[i].S+',年龄为:'+inttostr(MyArray^[i].I)); end; self.Memo1.Lines:=Alist; finally SetLength(MyArray^, 0); Dispose(MyArray); end; end; end.

    这段代码在Delphi 2007和delphi 7下是可以执行的,所以正确使用结构体数组和指针应该是这样的,已验证。

  • 相关阅读:
    平稳随机过程通过线性系统
    频谱分析的作用
    数字图像处理中的4邻接,8邻接与m邻接
    网络存储实验基础
    灰度变换
    MATLAB数字图像处理基础
    用MATLAB对信号做频谱分析
    关于 oracle10g、oracle client和plsql devement 三者之间的关系
    技术栈呢
    Linux编程
  • 原文地址:https://www.cnblogs.com/China3S/p/3286875.html
Copyright © 2011-2022 走看看