I'm trying to do the following thing:
#include <stdio.h>
typedef unsigned char Set[128];
Set A; //Global variable
void main()
{
A[0] = 1;
A[1] = 2;
A[2] = 3;
printf("%x, %x, %x\n", A, &A, &A[0]);
printf("%u, %u, %u\n", A[0], A[1], A[2]);
Set *p;
p = A; //Same result with: p = &A;
printf("%x, %x, %x\n", p, &p, &p[0]);
printf("%u, %u, %u\n", p[0], p[1], p[2]);
}
The first and third prints are fine - I get to see the addresses of the two variables, and for 'p' the address it points on. I want 'p' to point on 'A' so I'll be able to access to the values in the array of 'A' through 'p', but it doesn't work - the values at the fourth print are not as the second, it's not printing the values of the array. how can I create a pointer to 'Set' variable type?
p = Ais invalid. Assuming a high enough warning level the compiler would have mentioned it to you. Take the compiler's warning(s) serious.