Pointer row addresses have unexpected numbers

N

Nobody

What a bullshit.

But then again the C language is bullshit.

So what you are saying is you are either wrong, or you are incomplete.

It turns out you are not wrong, it turns out you are incomplete.

The correct answer is it depends on the pointer TYPE.

When defined, the difference between two pointers is always the number of
elements between them. I.e. the number of bytes divided by the size of an
element. This makes addition and subtraction consistent, i.e. if
"p + n == q" then "q - p == n".

Maybe you should learn to read before you imply that people are incorrect
when what is actually incorrect is your interpretation of what was written.
 
S

Seebs

Maybe you should learn to read before you imply that people are incorrect
when what is actually incorrect is your interpretation of what was written.

"Skybuck Flying" is a troll trying to start up language flame wars. Ignore
him. (Followups set to just one group.)

-s
 
S

Skybuck Flying

Nobody said:
When defined, the difference between two pointers is always the number of
elements between them. I.e. the number of bytes divided by the size of an
element. This makes addition and subtraction consistent, i.e. if
"p + n == q" then "q - p == n".

Maybe you should learn to read before you imply that people are incorrect
when what is actually incorrect is your interpretation of what was
written.

Ah I see you are correct, again my mistake.

Then again I already said I retracted everything I said ! LOL.

Bye,
Skybuck.
 
S

Skybuck Flying

procedure Main;
var
vArray : array[0..9] of integer;
vA : pointer;
vB : pointer;
vC : pointer;

vFuckYouBitchesA : Pbyte;
vFuckYouBitchesB : Pbyte;
vFuckYouBitchesC : Pbyte;
begin
vA := @vArray[4];
vB := @vArray[5];
// vC := vB - vA;

writeln( integer(vC) );


vFuckYouBitchesA := @vArray[4];
vFuckYouBitchesB := @vArray[5];
vFuckYouBitchesC := vFuckYouBitchesB - vFuckYouBitchesA;

Now that I have Delphi XE this code still didn't compile:

It turned out this does actually work... at least the minus operator is
working.

The problem seemed to be with the assignment.

Since Delphi is strongly typed assigning an integer result to a Pbyte is
considering an error... which is a bit weird but ok...

This typecast fixes it:

vFuckYouBitchesC := Pbyte( vFuckYouBitchesB - vFuckYouBitchesA );

So this does reduce the number of typecasts needed ;)

Bye,
Skybuck.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,083
Messages
2,570,589
Members
47,211
Latest member
JaydenBail

Latest Threads

Top