In this code i want to user to input numbers in the function then print the array in the main method, but when i try to print in the main method it gives me random numbers.
for eg: 1 2 3 gives 1 3 1895586112
void arrayInput(int *arr) {
int x;
int y;
int z;
printf("enter 3 numbers =");
scanf("%d %d %d", &x,&y,&z);
arr[0]=x;
arr[1]=y;
arr[2]=z;
}
int main(int argc, char **argv){
int *arr[3];
arrayInput(&arr);
int i;
for(i=0; i<3; i++)
{
printf("%d ", arr[i]);
}
}
I want to change the array values without changing the method or param type
int *arr[3];->int arr[3];-Wall -Wextra -Werror.