Unknown Error Message

Not sure what it means, or what is triggering this error.

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
85
86
87
88
89
90
91
92
#include <iostream>
#include <iomanip>
#include <string>
#include <stdlib.h>
#include <math.h>

using namespace std;

int search(int arrray[],int element);
int copysearch();
void fill(int arrray[], int copyarrray[]);
void display(int arrray[]);
void sort(int arrray[]);

	int main()

{
	int window;
	int num;
	int result;
	int arrray[20];
	int copyarrray[20];

	fill(arrray, copyarrray);

	sort(copyarrray);
	
	num = copysearch();

	result = search(arrray,num);

	if (result != -1)
		cout << "\nThe largest element was found at index " << result << "." << endl;

	display(arrray);

	cin >> window;

return 0;

}

void fill(int arrray[],	int copyarrray[20])
{
	srand(1);
		for(int i = 0; i < 20; i++)
		{
			arrray[i] = rand() % 100;
			copyarrray[i] = rand() % 100;
		}
}

int copysearch(int copyarrray[])
{
	return copyarrray[19];
}

void display(int arrray[])
{
	for(int x = 0; x < 20; x++)
		cout << arrray[x] << "  ";
}

void sort(int copyarrray[])
{
     int i, j, key, numLength = 20;
     for(j = 1; j < numLength; j++)
    {
           key = copyarrray[j];
           for(i = j - 1; (i >= 0) && (copyarrray[i] > key); i--)
          {
                 copyarrray[i+1] = copyarrray[i];
          }
         copyarrray[i+1] = key;
     }
     return;
}

int search(int arrray[],int element)
{
	int index;
	int var;

	for(index = 0; index < 10; index++)
	{
		if (element == arrray[index])
		{
			var = index;
		}
	}
	return var;
}


The error log says:

1
2
3
1
1>Code.obj : error LNK2019: unresolved external symbol "int __cdecl copysearch(void)" (?copysearch@@YAHXZ) referenced in function _main
1>C:\Users\bmleeper\Desktop\C++\Projects\Chapter 9\Prog10\Debug\Prog10.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
You forgot to include the parameter list in your forward declaration for "copysearch()", so now the linker doesn't know where to look for it.
error LNK2019: unresolved external symbol "int __cdecl copysearch(void)"


Your function definition doesn't agree with the prototype in terms of parameters.

function prototype takes no parameters
int copysearch();

function call sends no parameters
num = copysearch();

but function definition expects a parameter
int copysearch(int copyarrray[])
Last edited on
Line 10: int copysearch();
Line 53:int copysearch(int copyarrray[])

The error says it can't find an implementation of line 10.
Topic archived. No new replies allowed.