I tried to reverse an array using only pointers. The program runs without any errors but it doesn't reverse the array. What's wrong with my code?
#include <stdio.h>
#define SIZE 10
void arrayReverseOutput(int * arr);
void arrayInput(int * arr);
void printArray(int * arr);
int main(void)
{
int arr[SIZE] = { 0 };
arrayInput(arr);
arrayReverseOutput(arr);
printArray(arr);
system("PAUSE");
return 0;
}
void arrayInput(int * arr){
int i = 0;
for (i = 0; i < SIZE; i++){
scanf("%d",(arr+i));
}
}
void arrayReverseOutput(int * arr){
int i = 0;
int k = SIZE-1;
int temp = 0;
for (i = 0; i < SIZE; i++){
temp = *(arr+i);
*(arr+i) = *(arr + k);
*(arr + k) = temp;
k--;
}
}
void printArray(int * arr){
int i = 0;
for (i = 0; i < SIZE; i++){
printf("%d ", *(arr+i));
}
}