Am currently working on porting some old C Library to C# but have a bit of trouble understanding a certain piece of Code containing Pointers.
Am not the best when it comes to C so i might be lacking some understanding.
unsigned int block[2];
// --- inside a function
unsigned int *block; // only got access to this pointer not the array
unsigned long left, right;
// some math
*block++ = right; // these lines are the important bit i dont quite get
*block = left;
now...
right
left
Now what i have trouble wrapping my head around is how the end result (blocks[]
) looks.
(Sadly cant just debug it and take a peek bc I only have dont really know how id do that with a lib binary...)
Would be fairly simple if left
and right
were uints aswell but they are both ulongs so theres probably some sort of overwriting going on right?
Am a little confused / lost on this one... Maybe some of you with some better C knowledge can help me out ^^
This is basically doing:
block[0] = (unsigned int) right;
block[1] = (unsigned int) left;
And casting unsigned long
to unsigned int
simply discards the excess high order bits.