I'm new to C and pointers and I'm trying to work out a function that takes an array of pointers and an array of ints, and returns the two added together. I.e. at each index, the int of the array is added to the int at the address of the pointer. My plan of action is to turn the array of pointers into a regular array. To do so I have this code:
//the array arr has already been initialized and the array of pointers is int *x[]//
for (int i=0;i<length;i++){
arr[i]=*x[i];
}
This doesn't work as the code runs but the output is a very large number when it should be a small int under 100. Am I dereferencing the pointer wrong?