字符数组可以给string赋值
但反过来就不行;
还是看代码吧
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, Grids, DBGrids, StdCtrls;
type
TForm1 = class(TForm)
DBGrid1: TDBGrid;
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
Button1: TButton;
procedure ADOQuery1BeforePost(DataSet: TDataSet);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ADOQuery1BeforePost(DataSet: TDataSet);
begin
if DataSet.FieldByName('mz').AsString <> '02'then
begin
ShowMessage('aaa');
Abort;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
a: string;
b: array[0..4] of char;
p: ^string;
q: ^char;
begin
a:= 'abcd';
// b[0]:= 'a';
// b[1]:= 'b';
// b[2]:= 'c';
// b[3]:= 'd';
// a:= b
//可以
// ShowMessage(a);
// b[0]:= a[1];
b[1]:= a[2];
b[2]:= a[3];
b[3]:= a[4];
ShowMessage(b[3]);
p:= @a;
ShowMessage(p^);
q:= @a[1];
ShowMessage(q^);
end;
end.