Lazarus
Miscellaneous => Documentation (Maintaining -) => Topic started by: funlw65 on December 29, 2021, 08:02:12 am
Title:
S variabile not a Null terminated string
Post by:
funlw65
on
December 29, 2021, 08:02:12 am
Regarding the example from this wiki page, S variable is not a Null terminated string.
https://www.freepascal.org/docs-html/ref/refsu12.html#x35-460003.2.7
Title:
Re: S variabile not a Null terminated string
Post by:
winni
on
December 29, 2021, 08:51:21 am
Hi!
The variable S would be a null-terminated string if the declaration was right.
'This is a null-terminated string.'#0
is longer than 30 chars. Change the declaration to
Var S : String[40];
Then everything is ok.
Original code:
Code: Pascal
[Select]
[+]
[-]
Program
three
;
Var
S
:
String
[
30
]
;
P
:
PChar
;
begin
S
:
=
'This is a null-terminated string.'
#0
;
P
:
=
@
S
[
1
]
;
WriteLn
(
P
)
;
end
.
Winni
PS.: The nonsense ' was done by the Forum software
Title:
Re: S variabile not a Null terminated string
Post by:
funlw65
on
December 29, 2021, 09:40:43 am
Yes, that was the error - I wanted to see if someone counts the chars in the string :) .
Title:
Re: S variabile not a Null terminated string
Post by:
af0815
on
December 29, 2021, 03:22:53 pm
So it should be a Bug Report against the documentation .
( and against the forumsoftware with #39 too )
TinyPortal
© 2005-2018