Why am I getting error LINK2019 and LINK1120?

Every time I try to run this code I get those two errors. I don't see any missing semi-colons or anything? There are no other errors besides those two so I don't know what's going on. My math calculations might be wrong and I can't even compile to check how the program runs! Please help.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;

//function prototype
double MedianF (int *, int);
void arraySort (int *, int);

int main ()
{
	int *MyArray = nullptr;
	int elements;
	double MEDIAN;

	cout << "How many elements?" << endl;
	cin >> elements;

	MyArray = new int[elements];

	MEDIAN = MedianF (MyArray, elements);

	cout << "The median is..." << MEDIAN << endl;

	delete [] MyArray;
	MyArray = nullptr;

	system("pause");
	return 0;
}

double Median (int *Array, int Elem)
{
	 double median = 0.0;
 
    // First of all, sort our numbers.
    arraySort(Array, Elem);

    int mid = 0;
 
    // If array is even number of elements, find the middle element
    // Size of array split in 2, since it is converted to int, it drops fraction
    // subtract 1 because array is zero index.

    if((Elem % 2) == 0)
    {
        mid = (Elem / 2) - 1;
        median = (Array[mid] + Array[mid + 1]) / 2;
    }
    else
    {
        // If array is odd, find middle term by dividing in half, let it drop
        // the fraction when casting ot int. Use middle point to get value.
        mid = (int)(Elem / 2);
        median = Array[mid];
    }
    return median;

}

void arraySort (int *Array1, int Elem1)
{
	int startScan;
    int minIndex;
    int minElem;
 
    for (startScan = 0; startScan < (Elem1 - 1); startScan++)
    {
        minIndex = startScan;
        minElem = *(Array1 + startScan);
        for (int index = startScan + 1; index < Elem1; index++)
        {
            if ((*(Array1 + index)) < minElem)
            {
                minElem = *(Array1 + index);
                minIndex = index;
			}
        }

        *(Array1 + minIndex) = *(Array1 + startScan);
        *(Array1 + startScan) = minElem;
    }
}
Please copy and paste the errors here; just stating the error number isn't much help.
firedraco,

Error 1 error LNK2019: unresolved external symbol "double __cdecl MedianF(int *,int)" (?MedianF@@YANPAHH@Z) referenced in function _main C:\Users\Thomas\Documents\C++ practice\Function Median Pointers\Function Median Pointers\Source.obj Function Median Pointers

Error 2 error LNK1120: 1 unresolved externals C:\Users\Thomas\Documents\C++ practice\Function Median Pointers\Debug\Function Median Pointers.exe Function Median Pointers
Where is the function MedianF defined in the OP? There is a function definition that is similar in name: Median... but that's not MedianF, is it?
cire,

Thanks. I missed that when I was checking.

Thanks again,

MisterTams
Topic archived. No new replies allowed.