Your initial attempt is incorrect in "formal" C, as pointer arithmetic does not apply to void * pointers. However, some compilers support pointer arithmetic on void * pointers as a non-standard extension (GCC is a notable example). In such void * compilers, pointers are treated as char * pointers for arithmetic purposes. And yours
for(i = 0; i < 3; i++) printf("%i\n", *((int *) (data + sizeof(int) * i)));
will work in such a compiler as intended.
With a more pedantic compiler, you can save the day by doing
for(i = 0; i < 3; i++) printf("%i\n", *((int *) ((char *) data + sizeof(int) * i)));
But in any case, the above two pieces of code are hopelessly complex. They have some meaning as examples when you just study pointer arithmetic, but that’s all that’s good for them.
What you really need is just
for(i = 0; i < 3; i++) printf("%i\n", ((int *) data)[i]);
You can enter an optional int * pointer, like the other suggested answers, to make your code even more readable. But it is up to you.
source share