dynamic creation of arrays of pointers to arrays of pointers

I'm trying to write a function that takes a 32bit address and a data to store at this address.

I'm watning to take the 32 bit memory address eg 0x12345678 and split it
into 4 x 2 bytes
12, 34, 56, 78

then each of the 4 entries is at most a 256 entry array.eg
FF, FF, FF, FF

So in this example, 0x12 points to 0x34 in the second array, which
points to 0x56 in the third array, which finally points to 0x78 in the
last array.
This last array holds the actual data.

After successfully doing 0x12345678, say I might get a read for
0x1234AABB. So, the first and second pointers already exist, but I then have to create and write to dynamically created arrays.
The arrays need to have all entries set to NULL so that i know whether to follow the pointers to overwrite a previously entered value or create new arrays and pointers.

It all looks good and simple in the pseudo code I've written up but I'm having trouble coding it.
I'm currently trying to deal with the first entry case, ie all array elements are NULL, but I'm getting confused with the pointers and creation of new arrays.

 ``12345678910111213141516171819202122232425262728293031323334`` ``````void cpu::store(unsigned int mem_add,unsigned int mem_val) { int first = (mem_address&4278190080)>>24; int second = (mem_address&16711680)>>16; int third = (mem_address&65280)>>8; int fourth= (mem_address&255); if (A1[first]==NULL) { int** A2=new int*[256]; for (i=0;i<256;i++) { A2[i]=NULL; } int** A3=new int*[256]; for (i=0;i<256;i++) { A3[i]=NULL; } unsigned int* A4=new unsigned int[256]; for (i=0;i<256;i++) { A4[i]=0; } A1[first]=A2; A2[second]=A3; A3[third]=A4; A4[fourth]=mem_val; } }``````

A1 has been declared as
`int* A1[256] ;`

Any tips on where I'm going wrong?

I've played with it a bit now and got it compiling, However, the last 4 lines of code are not storing the correct values.
code is now:

 ``1234567891011121314151617181920212223242526272829303132333435`` ``````void cpu::store(unsigned int mem_add,unsigned int mem_val) { int first = (mem_add&4278190080)>>24; int second = (mem_add&16711680)>>16; int third = (mem_add&65280)>>8; int fourth= (mem_add&255); if (A1[first]==NULL) { cout<<"here"<
This whole idea is very dangerous. Why don't you let the OS provide you with the address to store your data? You have a high probablity of overwriting memory that you don't want to overwrite resulting in an un-stable computer and potential crashing of your program or the OS. No one does this sort of recless programming for a very good reason; its dangerous. Just use the new operator as its designed to be used and be happy with it. Or are you attempting to inject data into a program that's already running or even the OS, doesn't sond very legitimate!