I just have a quick question regarding how a char array works in regards to a memory pool and allocating pointers of other variable types to it. I am working on an assignment which uses a char array for a memory pool and I need to be able to allocate pointers to it, and I have read some info on the subject but am not quite understanding one part which is how the actual allocation works such as:
const int poolSize = 60000;
char pool[poolSize];
void* allocate(int aSize)
{
//.....
return ((void*) 0);
}
long* pointer;
pointer = (long *) allocate(sizeof(long));
*pointer = 0xDEEDEEEF;
I just don't quite get exactly how this works since a char is 1 byte while a long should be 4 and so how does something like this work when I need to allocate 4 spots in the array to the one long pointer variable? Also feel free to give examples and explanations but please don't give away how the entire program should work as I would like to figure it out myself once I understand exactly how this part works. Thanks