Your array
is a void
-pointer. And void
(in C) means 'has no type'. So when you dereference it (like array[0]
) the compiler has no idea what that means.
To access bytes you need a char
type, which is actually the C-equivalent of a byte (a remnant from the days when characters would still fit into (8-bit) bytes).
So declare your array as:
char * array = malloc(12);
Also note that you don't have to cast the result of malloc
(especially in your case since it already returns a void *
). And, if you want just the 12 bytes and only use them locally (within the function or translation-unit that declares it) then you can just use a 'proper array':
char array[12];
This has the added bonus that you don't need to free
it afterwards.