I'm trying to set the 0th element of an unsigned char array to the address of the nth element of a separate unsigned int array. I'm not sure if my syntax match ups with the addresses and pointers. (This is my main concern, in addition to any potential type conflicts.) I'm using chars because my assignment requests me to keep the data in an element to under 8 bits. This is a snippet of my implementation:
unsigned int memory_size = 100; // size of array 1
unsigned int other_memory_size = 100; // size of array 2
unsigned char *memory = NULL; // array 1
unsigned int *other_memory; // array 2
memory = new unsigned char (memory_size); // declare size
other_memory = new unsigned int (other_memory_size); // declare size
Finally, I want the first element in memory to be the address of an element in the other_array.
memory[0] = &other_memory[0];
Eclipse returns this error:
invalid conversion from 'unsigned int*' to 'unsigned char'
To resolve this, I changed all char declarations above to int declarations. The new error is:
invalid conversion from 'unsigned int*' to 'unsigned int'
Leading me to believe the types aren't the main issue here. Am I declaring points incorrectly, referencing addresses inappropriately? Please advise.