You're off by one:
Code:
for (i=0; i < a_elem; i++) {
printf("\nelement: ");
scanf("%d ", &i_array[index]);
index++;
}
index=a_elem;
When exiting this loop your index is pointing at the
NULL terminating your initial array.
So when you reverse:
Code:
for (i=0; i< a_elem; i++) {
rev_array[rev_index]=i_array[index];
index--;
rev_index++;
}
Your initial value will be an
int representing
NULL as the first value in the reversed array. And since you're testing
i against the array size, you'll miss the first value in your initial array.