Guest:
Register
|
Login
|
Member List
|
Search
|
Statistics
|
FAQ
Language
----------
Simplifed Chinese
Traditional Chinese
English
CnPack Forum
»
技术板块灌水区
» CnPackTip#3:认识静态数组 array[m,n] of x
‹‹ Last Thread
|
Next Thread ››
Poll
Trade
Reward
Activity
Printable Version
|
Email to Friend
|
Subscription
|
Favorites
Subject: CnPackTip#3:认识静态数组 array[m,n] of x
skyjacker
版主
茶农
UID 2239
Digest Posts
9
Credits 617
Posts 269
点点分 617
Reading Access 100
Registered 2006-6-8
Status Offline
#1
Post at 2007-3-7 15:37
Profile
|
Blog
|
P.M.
|
CnPackTip#3:认识静态数组 array[m,n] of x
CnPackTip#3:认识静态数组 array[m,n] of x
Written by SkyJacker
http://www.cnpack.org
CnPack IV QQ Group: 130970
2007-3-7
年前 passion 和 Bahamut讨论过。
这里总结一下,有误之处请指出。
var
A: array[0..0] of Char; // 表示一个字符。即 array[0..0] 表示一个此类型的元素
B: array[0..10] of Char; // 下标从0开始的Char数组可以把数组名当作PChar来使用;也可以用字符串直接赋值
C: array[1..10] of Char; // 普通数组
D: array[-1..10] of Byte; // 普通数组
I: Integer;
begin
A[0] := 'A';
B := 'BC';
C[1] := 'D';
D[-1] := 2;
D[0] := Ord('F');
D[1] := Ord('A');
for I := - 1 to 3 do
begin
ShowMessage(IntToStr(D[I]));
end;
ShowMessage(A + '-' + B + '-' + C);
end;
1、关于"Zero-based character arrays" 的 Delhpi Help:
//An array type of the form array[0..x] of Char is called a zero-based character array.
//Zero-based character arrays are used to store null-terminated strings and are compatible with PChar values
2、array[0..0] 的意义是什么?
是为了方便传递 array 类型的参数。
可以参考 CnPackTip#4 <<New() 的学习>>
3、数组下标可以为负。
一壶清茶煮青春.
Passion
(LiuXiao)
管理员
UID 359
Digest Posts
19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
#2
Post at 2007-3-7 15:43
Profile
|
Blog
|
P.M.
Tip#4在哪儿?
kendling
(小冬)
高级版主
MyvNet
UID 703
Digest Posts
5
Credits 978
Posts 580
点点分 978
Reading Access 101
Registered 2005-2-18
Location 广东
Status Offline
#3
Post at 2007-3-7 16:09
Profile
|
Site
|
Blog
|
P.M.
|
|
对哇,还没有,怎么参考?
小冬
http://MyvNet.com
Passion
(LiuXiao)
管理员
UID 359
Digest Posts
19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
#4
Post at 2007-3-7 17:11
Profile
|
Blog
|
P.M.
不过内容应该差不多有了,就在今天的群聊天记录里。小冬没看见?
skyjacker
版主
茶农
UID 2239
Digest Posts
9
Credits 617
Posts 269
点点分 617
Reading Access 100
Registered 2006-6-8
Status Offline
#5
Post at 2007-3-7 22:32
Profile
|
Blog
|
P.M.
|
感叹一下:事事之间可能有不可预知的关联啊。
今天随手转了那篇 pascal/c 指针的区别,
之后,看到清风的问题就用到了。
再看清风的New问题,又看到了 array[0..0],就把年前的PChar总结了一下。
看New时,又明白了 <pascalc 指针区别> 中的 “New()只能获得对象的单个实体的内存大小”。
不折不扣转了个好圈!
纪念一下!
[
本帖最后由 skyjacker 于 2007-3-7 22:41 编辑
]
一壶清茶煮青春.
Passion
(LiuXiao)
管理员
UID 359
Digest Posts
19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
#6
Post at 2007-3-8 05:40
Profile
|
Blog
|
P.M.
该文已塞入文档中心。
kendling
(小冬)
高级版主
MyvNet
UID 703
Digest Posts
5
Credits 978
Posts 580
点点分 978
Reading Access 101
Registered 2005-2-18
Location 广东
Status Offline
#7
Post at 2007-3-8 09:06
Profile
|
Site
|
Blog
|
P.M.
|
|
Passion:我这两天都忙,没留意群里的聊天。
小冬
http://MyvNet.com
skyjacker
版主
茶农
UID 2239
Digest Posts
9
Credits 617
Posts 269
点点分 617
Reading Access 100
Registered 2006-6-8
Status Offline
#8
Post at 2007-3-8 09:55
Profile
|
Blog
|
P.M.
|
Tip#4 我先预申请了这个号.
发现要明白 New, 还必须熟悉 TypeInfo.
不然搞不明白,申请完内存后,初始化内存部分.
procedure _InitializeArray(p: Pointer; typeInfo: Pointer; elemCount: Cardinal);
[
本帖最后由 skyjacker 于 2007-3-8 09:57 编辑
]
一壶清茶煮青春.
kendling
(小冬)
高级版主
MyvNet
UID 703
Digest Posts
5
Credits 978
Posts 580
点点分 978
Reading Access 101
Registered 2005-2-18
Location 广东
Status Offline
#9
Post at 2007-3-8 16:38
Profile
|
Site
|
Blog
|
P.M.
|
|
期待Tip#4
小冬
http://MyvNet.com
Poll
Trade
Reward
Activity
CnPack Forum
CnPack English Forum
> CnWizards IDE Wizards
> CVSTracNT
> Announcements & Others
All times are GMT++8, the time now is 2024-11-25 12:21
Powered by
Discuz!
5.0.0
© 2001-2006
Comsenz Inc.
Processed in 0.010162 second(s), 9 queries , Gzip enabled
TOP
Clear Cookies
-
Contact Us
-
CnPack Website
-
Archiver
-
WAP
Member's CP Home
Edit Profile
Credits Transaction
Public User Groups
Buddy List
Main
Page Views
User Agents
Posts History
Top Forums
Top Threads
Post Ranking
Credit Ranking
Online Time
Team
Moderation Stats