To get the vector address simply use its own variable, as I had already informed in comment on another question . The point is that the placeholder of correct printf()
formatting is %p
to receive a pointer. This will require a cast (void *)
(generic pointer) to fit correctly (at least in compilers with more secure encoding options).
The same goes for the element values. But there you will use the &
operator since it is normal to get their values.
#include <stdio.h>
int main(){
int vec[] = {52, 13, 12, 14};
printf("Endereço de vetor %p\n", (void*)vec);
printf("vec[0] = %p, vec[1] = %p, vec[2] = %p, vec[3] = %p\n", (void*)&vec[0], (void*)&vec[1], (void*)&vec[2], (void*)&vec[3]);
}
See working on ideone .