Re: is this correct C? (char*)spm += spm->partitionMapLength;



O_TEXT schrieb:

gcc answers no:

./a.out
spm : 0x2b3e202a8ca0
spm : 0x2b3e202a8ca5
spm : 0x2b3e202a8ccd

int main()
{
long *spm;
printf ("spm : %p \n", spm );
spm = ( long *) ((char*)spm + 5);
printf ("spm : %p \n", spm );
spm += 5;
printf ("spm : %p \n", spm );
return 0;
}

In the first example, spm is increased by 5 * sizeof(char), i.e. 5
bytes. In the second example, spm is increased by 5 * sizeof(long), i.e.
whatever it is in your implementation (I'm too lazy to calculate).

Pointer arithmetic is dependant on the type the pointer points to.

Greetings,
Johannes

--
"Viele der Theorien der Mathematiker sind falsch und klar
Gotteslästerlich. Ich vermute, dass diese falschen Theorien genau
deshalb so geliebt werden." -- Prophet und Visionär Hans Joss aka
HJP in de.sci.mathematik <4740ad67$0$3811$5402220f@xxxxxxxxxxxxxxx>
.