In the code below, when writing to the memory why does this line of code:
temp = ((int*) mem_allocate + i); 
not increment the memory locations in consecutive 4 bytes? The memory locations resulted due to this are:
0x20000818 
0x20000828
0x20000848 
...
and so on.
I wanted to write the data in
0x20000818
0x2000081C
0x20000820 
...
and so on.
#include <stdio.h>
#include <stdlib.h>
int main()
{
   int n = 1024; 
   int* mem_allocate;
   int loop = 0;
   int i = 0; 
   mem_allocate = (int*) malloc(n*sizeof(int));    
   for(i=0; i<40; i++) 
   {
      int* temp; 
      temp = ((int*) mem_allocate + i);
      i=i+3; 
      *temp =0xAAAAAAAAu; 
      *mem_allocate = *temp; 
       mem_allocate = temp;
      if (i == 40)
      {
          loop = 1; 
      }
   }
   if (loop == 1) 
   {
      free(mem_allocate); 
   }
   return 0; 
}
 
     
    