An array variable name can be considered to be a constant pointer. While it can be treated as a pointer, the variable name value can not be modified.
For instance we can create an array and then access an element of the array by either using subscripts or by using pointer arithmetic and dereferencing using the asterisk (*) symbol.
char myArray[20]; // an array of 20 characters
myArray[2] = 'C'; // assigning a value of the letter C to the third element of the array
*(myArray + 2) = 'K'; // assigning a value of the letter K to third element of the array
char *pmyArray; // a pointer to one or more characters, not yet initialized though.
pmyArray = myArray; // assigning the address of the first element of the array to my pointer
*(pmyArray + 2) = 'J'; // assigning a value of the letter J to third character after the character pointed to by pmyArray
The value of a pointer can be incremented. For example:
pmyArray++; // increment by one position
pmyArray = pmyArray + 1; // increment by one position
pmyArray += 1; // increment by one position
However the array name is not a true pointer variable it is more like a pointer constant so an array name can not be incremented in the way that a pointer variable can be incremented. The nice thing about a pointer that is incremented is that the actual address is increased by the number of bytes needed to move the pointer to the address of the next memory address for the type.
For example:
char myArray[48];
char *pmyChar = myArray;
short *pmyShort = (short *)myArray; // use cast to assign address of array to pointer
long *pmyLong = (long *)myArray;
With these statements, the three different pointers will all point to the same memory address, the address where the character array myArray begins. However if we then increment each of these pointers like so:
pmyChar++; // increment by one to next character
pmyShort++; // increment by one to next short
pmyLong++; // increment by one to next long
each of these pointers will now contain a different address. The pointer pmyChar will contain the address of the second element of the character array myArray because pmyChar is a char pointer just as the myArray is a char array.
The pointer pmyShort will contain the address of the third element of the character array myArray because pmyShort is a short pointer, a short contains two bytes (each char is a byte), and the incrementing of pmyShort is done by increasing the address contained in the pointer variable by the size of a short and not by the size of a char.
The pointer pmyLong will contain the address of the fifth element of the character array myArray because pmyLong is a long pointer, a long contains four bytes, and the incrementing of pmyLong is done by increasing the address contained in the pointer variable by the size of a long and not by the size of a char.
You can also have a pointer to a pointer like the following:
char myArray[48];
char *pmyArray;
char **pmyPointerToMyArray;
pmyArray = myArray; // pointer to myArray
pmyPointerToMyArray = &pmyArray; // address of pointer to myArray
Then you can do something like this:
pmyArray++; // increment to second element of myArray
*(pmyArray) = 'J'; // set the second element of myArray to letter J
*(*pmyPointerToMyArray) = 'K'; // set the second element of myArray to letter K
What this last statement does is to get the value pointed to by pmyPointerToMyArray, which is the address of the variable pmyArray, and to then use that value as the address of a character to put the letter K.
*M = '1'andM++should suffice.You dont need*(char*)&M = '1'and&M++.unsigned char *X=M- please just post a full code example that to stop people trying to guess what random things your are trying to do