P
pointer noob
Hi,
I am trying to write a bit of code to iterate through memory addresses
and if the address is divisable by 2 then write one byte, if not write
a different byte. I am having trouble with the pointer to the address
incremented by for loop.
unsigned long i;
for(i=0xB8000; i<0xC0000; i++)
{
if (i % 2)
*(short *)i = 0x20;
else
*(short *)i = 0x07;
}
Does this look right? I found the *(short *) syntax online in another
bit of code that was used in a if statement, but I am not sure how this
statement works. My guess is it declares the data type at the address
being pointed to, but I cant find anything to confirm that. Or if
someone knows a better way to accomplish this, I would be very
grateful.
In case anyone is wondering, this chunk should blank a video screen.
Thanks for your time...
I am trying to write a bit of code to iterate through memory addresses
and if the address is divisable by 2 then write one byte, if not write
a different byte. I am having trouble with the pointer to the address
incremented by for loop.
unsigned long i;
for(i=0xB8000; i<0xC0000; i++)
{
if (i % 2)
*(short *)i = 0x20;
else
*(short *)i = 0x07;
}
Does this look right? I found the *(short *) syntax online in another
bit of code that was used in a if statement, but I am not sure how this
statement works. My guess is it declares the data type at the address
being pointed to, but I cant find anything to confirm that. Or if
someone knows a better way to accomplish this, I would be very
grateful.
In case anyone is wondering, this chunk should blank a video screen.
Thanks for your time...