I wrote this code that works with array and it is divided into two files one that contains functions and another that contains main. But when I compile it, it gave me an output error as following. Do you have any advice on how can I fix this?
functions.c:
#include <string.h>
#include <stdio.h>
void return_array(int a[], int n) {
int c, d, min, max, location = 1;
int b[n];
for (c = n - 1, d = 0; c >= 0; c--, d++)
b[d] = a[c];
for (c = 0; c < n; c++) {
a[c] = b[c];
}
printf("Array after reverse of elements:\n");
for (c = 0; c < n; c++) {
printf("%d\n", a[c]);
}
return;
}
void return_min_max(int a[], int n, int * min, int * max) {
for (int i = 1; i < n; i++) {
if (a[i] > * max) {
* max = a[i];
}
if (a[i] < * min) {
* min = a[i];
}
}
printf("Smallest element in array is: %d\n", * min);
printf("Largest element in array is: %d\n", * max);
return;
}
Errors:
6: error: multiple definition of `return_array'
29: error: multiple definition of `return_min_max'
:-1: error: collect2.exe: error: ld returned 1 exit status