Код
Character-pointer operators
Operator Operation Operand types Result type Example
+ pointer addition character pointer, integer character pointer P + I
...
You can use the + and - operators to increment and decrement the offset of a character pointer. You can also use - to calculate the difference between the offsets of two character pointers. The following rules apply.
If I is an integer and P is a character pointer, then P + I adds I to the address given by P; that is, it returns a pointer to the address I
characters after P.
Operator Operation Operand types Result type Example
+ pointer addition character pointer, integer character pointer P + I
...
You can use the + and - operators to increment and decrement the offset of a character pointer. You can also use - to calculate the difference between the offsets of two character pointers. The following rules apply.
If I is an integer and P is a character pointer, then P + I adds I to the address given by P; that is, it returns a pointer to the address I
characters after P.
Делаю инкремент указателя через inc() - все нормально, а вот если просто прибавлять смещение к указателю ругается "[Error]...: Operator not applicable to this operand type".
Проверяю на таком примере:
Код
p : ^char;
str : string[5];
begin
str := 'abc';
p := @str;
p := p + 1; // <--
str : string[5];
begin
str := 'abc';
p := @str;
p := p + 1; // <--
Как заставить указатель указывать на другое место в памяти используя смещение?