There are at least 3 basic ways to assign value to array element in C.
Say we have an integer array defined like this:
int an_array[3] = {1,2,3};We can change the value of each element using following three ways (there might me more ways).
1) Most common one, using array index.
an_array[0] = 10;
an_array[1] = 20;
an_array[2] = 30;
2) Using pointer, since array is implemented by pointer anyway.
*an_array = 10;
*(an_array+1) = 20;
*(an_array+2) = 30;
3) Using address casting, assuming integer type use 4 bytes on your machine. This method cast the pointer integer value to integer pointer and goes from there.
int addr = an_array;
*(int*)addr = 10;
*(int*)(addr+4) = 20; (change to addr+8 if your int is 8 bytes long)
*(int*)(addr+8) = 30; (change to addr+16 if your int is 8 bytes long)