I have a function definition that gets values for an array trough the user using scanf. This is what i have
void readInArray(int *arr, int size) {
int i;
printf("Enter your list of numbers: ");
for (i = 0; i < size; i++) {
scanf("%f", arr[i]);
printf("%d\n", arr[i]);
}
}
when i try to print the array i get an error at the line with scanf saying "format specifies type 'float *' but the argument has type 'int'".I tried changing %f to %d so that both scanf and printf have the same place holder
void readInArray(int *arr, int size) {
int i;
printf("Enter your list of numbers: ");
for (i = 0; i < size; i++) {
scanf("%d", arr[i]);
printf("%d\n", arr[i]);
}
}
but i still get the same error. How can i fix this?
scanftutorial show how to do this correctly?