Pascal的問題

2007-09-01 6:52 am
係pascal 內的command ''inc" 係有咩意思同用途~?

回答 (2)

2007-09-03 2:10 am
✔ 最佳答案
Inc (procedure)
Increments a variable.

Declaration
procedure Inc(var X [ ; N: Longint ] );

Sample Code:
{Inc.PAS}
{Sample code for the Inc procedure.}

var
IntVar: Integer;
LongintVar: Longint;
begin
Inc(IntVar);{ IntVar := IntVar + 1 }
Inc(LongintVar, 5);{ LongintVar := LongintVar + 5 }
end.

你可以試用下..咪知點用!
參考: Turbo Pascal for Windows 1.2 的Help檔
2007-09-01 7:08 am
Free Pascal supports pointer arithmetic as C does. This means that, if P is a typed pointer, the
instructions
Inc(P);
Dec(P);
Will increase, respectively decrease the address the pointer points to with the size of the type P is a
pointer to. For example
Var P : ^Longint;
...
Inc (p);
will increase P with 4. Normal arithmetic operators on pointers can also be used, that is, the following
are valid pointer arithmetic operations:
var p1,p2 : ^Longint;
L : Longint;
begin
P1 := @P2;
P2 := @L;
L := P1-P2;
P1 := P1-4;
P2 := P2+4;
end.
Here, the value that is added or substracted is multiplied by the size of the type the pointer points to.
In the previous example P1 will be decremented by 16 bytes, and P2 will be incremented by 16.
參考: ftp://ftp.freepascal.org/pub/fpc/docs-pdf/ref.pdf


收錄日期: 2021-04-13 13:14:23
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20070831000051KK06785

檢視 Wayback Machine 備份