In the below loop, I am attempting to copy data stored at the address of voidPtr. The data here is known to be an integer array of length count. I've read that casting this array to an int and then performing the copy (as shown below) should work.
int intArr[count];
for (int i = 0; i<count; i++){
intArr[i] = ((int*) voidPtr)[i];
}
However, when I attempt to print the array int by int, I am receiving a seg-fault.
for (int i = 0; i<count; i++){
printf("%d ", intArr[i]);
}
Any ideas?