I'm doing a project where I struck against this situation:
typedef unsigned char Page[16384];
unsigned char Memory[16384*64]={...values...};
void foo(Page* page);
Now as you can see Memory is composed of "Pages", now I would like to pass a Page to a function but a Page should be a POINTER to values of Memory (so indexes of a Page should be pointers to values of Memory). What I mean should be understand watching this:
Page tmp;
Memory[16400]=50;
tmp=(unsigned char[16384])&Memory[16384];//This is not possible but is what I would like to do
printf("Value should be 50: %d\n",tmp[15]);
Any suggestion?
Update 1: I need that Memory is a big array and not array of arrays (while actually they are the same if I'm not wrong), it's a project requirement (for university).
Update 2: Obviusly is a sample code, I used a macro for 16384 (and also for 16384*64), sizes can't change.
Update 3: I would like to preserve Page as unsigned char[16384] because I would like to use it to pass values that should be stored (so they aren't stored anywhere) but I think it's impossible in this way so I'll follow Tyler McHenry suggestion
Update 4: As Tyler McHenry stated, Update 3 doesn't make sense, so I'm explaining what I mean: I would like to use Page to pass values to functions that must store those values to a "swap file" (is a system memory simulator), so actually there are some cases where a Page will not be a reference to anything (just an array of values), but the problem in this way is that a page should be a pointer to part of Memory OR just a simple array of 16384 bytes, so 1 type for 2 things is a problem.
An example could be this:
typedef char Page[16384];
void WritePageToSwapFile(char* swapfilePath,Page* page);
...somewhere in a function...
Page myNewPage;
myNewPage[5]=23;
WritePageToSwapFile("swapfile",&myNewPage);
...somewhere else, in another function...
Page tmp;
Memory[16400]=50;
tmp=(unsigned char[16384])&Memory[16384];//This is not possible but is what I would like to do
WritePageToSwapFile("swapfile",&tmp);
I don't think I can do both things with the same type