шаблон
var
point: pointer;
PointInt: ^Longint;
i : Longint;
const
s: Ansistring = 'Ansistring';
begin
{программа}
end.
программа1
writeln(length(s));
получаем exit code =216 (General Protection fault)
Цитата
The application tried to access invalid memory space. This can be caused by several problems:
1. Deferencing a nil pointer //не может быть, строка не пуста
2. Trying to access memory which is out of bounds (for example, calling move with an invalid length).
1. Deferencing a nil pointer //не может быть, строка не пуста
2. Trying to access memory which is out of bounds (for example, calling move with an invalid length).
значет мы вышли за границы.. Чего?
читая
Цитата
If the string is empty (’’), then the internal pointer representation of the string pointer is Nil. If the string is not empty, then the pointer points to a structure in heap memory.
зайдем с другой стороныпрограмма2
point:=s[0];
PointInt:=point;
i:=PointInt^;
writeln(i);
но опять получаем ошибку(правда теперь еще при компиляции)
Цитата
Element zero of an ansi/wide- or longstring can't be accessed, use (set)length instead
но теперь вообще ничего не понимаем Добавлено через 9 мин.
есть идея...
может надо от того что находится на point отнимать point^?
бредовая идея...
Добавлено через 3 мин.
тобиш както так
i:=PointInt^-@(s[0]);
Сообщение отредактировано: compiler -