Casting a pointer to array to void*

S

Sortie

typedef float Vector[3];

Vector arr[2][2];
Vector *pv = &arr[0][0];

char c = 'a';

memcpy(pv[0][0], &c,1); /* incompatible type for argument 1 of
`memcpy' */





pv[0][0] refers a Vector, so why does it appear as if it refers
to a float?
 
B

Barry Schwarz

typedef float Vector[3];

Vector arr[2][2];
Vector *pv = &arr[0][0];

char c = 'a';

memcpy(pv[0][0], &c,1); /* incompatible type for argument 1 of
`memcpy' */

pv[0][0] refers a Vector, so why does it appear as if it refers
to a float?

If you had coded arr[0][0], your assertion about the first argument
would have been true.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top