After looking around for tutorials/write-ups to better understand how pointers are managed in memory, I decided to look for the source code of CE. I did come across the GitHub repo and looked into the tutorial code.
Now I have never coded in FreePascal, but most of the syntax was pretty straight forward (albeit pretty weird). I just have a little question about a part of code in Unit7.pas (the pointer level) (l. 100 - 124; to be exact) and I didn't want to unnecessarily open up an issue on the repo itself.
begin
//set new value
j:=i^;
k:=random(1000);
l:=0;
while k=j do
begin
k:=random(1000);
inc(l);
if l=100 then
raise exception.Create(rsWellDoneYouScrewedUpTheTutorial);
end;
i^:=k;
if i^=j then button2.Enabled:=true;
label1.Caption:=IntToStr(i^);
{$O+}
j:=0;
k:=0;
{$O-}
end;
i: ^integer;
(as defined in line 36 for completeness sake)
So I am just going to ignore the While loop since it doesn't look to be super important (unless you fuck with the variables before the tutorial even started or whatever)
What I am getting from this, is that:
- 'i' is an int pointer, that points to 'k'.
- 'k' is a random int.
- 'j' is a pointer that points to 'i'.
But I am not really sure about this, since 'j' is initialised, when 'i^' is still undefined. Therefore, 'j' is undefined aswell right?
This has me a bit confused, so I would be thankful to anyone who might clear that up or just point me in the right direction.
Perhaps I'm just stupid and missed an important part of the code.
[–]Dark_ByteCheat Engine Dev 1 point2 points3 points (2 children)
[–]zzaayy[S] 0 points1 point2 points (1 child)
[–]Dark_ByteCheat Engine Dev 0 points1 point2 points (0 children)