реклама на сайте
подробности

 
 
> Delphi, pointers.
hadrov
сообщение Jan 15 2009, 10:53
Сообщение #1


Участник
*

Группа: Участник
Сообщений: 15
Регистрация: 11-11-08
Пользователь №: 41 540



Из хелпа Дельфи:

Код
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.


Делаю инкремент указателя через inc() - все нормально, а вот если просто прибавлять смещение к указателю ругается "[Error]...: Operator not applicable to this operand type".

Проверяю на таком примере:
Код
    p   : ^char;
    str : string[5];

begin
    str := 'abc';
    p := @str;
    p := p + 1; // <--


Как заставить указатель указывать на другое место в памяти используя смещение?
Go to the top of the page
 
+Quote Post



Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 4th July 2025 - 06:52
Рейтинг@Mail.ru


Страница сгенерированна за 0.0137 секунд с 7
ELECTRONIX ©2004-2016