Hi all,
let's say we have an array of char (thus array of "bytes"):
and let's say the 1st element of array is stored at address "00000000", the 2nd one at "00000001", the 3rd one at "00000002", ... , and the last one at "00000999":Code:char pool[1000];
Code:printf("%d\n", &pool[0]); // == 00000000
printf("%d\n", &pool[1]); // == 00000001
printf("%d\n", &pool[2]); // == 00000002
.
.
.
printf("%d\n", &pool[999]); // == 00000999
And now the problem begins.
Let's say we have "a pointer to int" which we will give the address of the 1st element in array:
And now if we would like to "add some number to that pointer", let's say:Code:int* pInt = &pool[0]; // It takes "4" first elements in array (sizeof(int) == 4)
But "I want to" do that addition so that pointer will point to the address "00000001"!Code:pInt = pInt + 1; // "pInt" now points to address "0000003" and no to "00000001"
Is there any way to do it?
Thanks.