passing an array to the func.

Hi guys,

I have probelm for passing the two arrays which Questions[] & answers[] to FindFriend() function. I cannot pass it throw line 49. Can you please help out with this issue I don't have much time I was trying to figure this out but I couldn't. your help is highly appreciate it.

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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
  #include"StudentData.h"
#include <fstream>
#include <iomanip>
#include <cstdlib>
	using namespace std;

void LoadDatabase (fstream&);

void displayMenu();
void displayRecord();
void findFriends(string*,string*);
void updateRecord(fstream&, string[9], string[9]);
int numRec = 0;

StudentData *Students[MaxStudent];		// Array to hold Student Record
int similarities[100];	//Array to keep track of similarities of present person with all others
int tempIndexArray[100];	//Array that temporarily keeps track of persons indices while sorting

int main()
{	
	//StudentData *Students[MaxStudent];
	//The set of questions to ask The person.
	string questions[9] = {"What's Your First Name?",
							"What's Your Last Name?",
							"What is Your Major?",
							"What School do You attend?",
							"Where are You From?",
							"What is Your Gender?",
							"Who is Your Favorite Super Hero?",
							//"What's Your favorite Music?",
							"What's Your Favorite Sport?",
							//"What's Your Favorite Show?",
							"What's Your Favorite Food?",							
							};
	
	string answers[9];	// Array to Store Answewrs

	fstream inFile("Ans.txt");	// open Answers
	LoadDatabase(inFile);

	int choice;
	while(1)
	{
		displayMenu();
		cin >> choice;

		switch(choice)
		{
		case 1:  findFriends(questions,answers);
			break;
		case 2:// updateRecord(inFile, questions, answers);
			break;
		}
	}


	system("PAUSE");
}
void findFriends(string *questions, string *answers)
{

	for (int i= 0; i< numRec; i++)
	{
		tempIndexArray[i] = i;
	}
	// ask questions
	for (int i= 0; i< 11; i++)
	{
		cout << questions[i];
		cin >> answers[i];
	}
	
	//Compare Answers
	for (int i= 0; i< numRec; i++)
	{
		similarities[i] = 0;
		if (answers[2] == Students[i]->getMajor())	// if major is similar
			similarities[i]++;
		if (answers[3] == Students[i]->getSchool())	// if School is similar
			similarities[i]++;
		if (answers[4] == Students[i]->getCountry()) // if Country is similar
			similarities[i]++;
		if (answers[5] == Students[i]->getGender()) // if Gendeer is similar
			similarities[i]++;
		if(answers[6] == Students[i]->getHero())	// if Hero is similar
			similarities[i]++;
		if(answers[7] == Students[i]->getSport())	// if sport is similar
			similarities[i]++;
		if(answers[8] == Students[i]->getFood())	// if sport is similar
			similarities[i]++;
	}
	// Used to sort and display people with most Similarities
	for (int i= 0; i< numRec-1; i++)
	{
		for (int j= 0; j<numRec-1; j++)
		{
			if(similarities[j] < similarities[j+1])
			{
				int temp = similarities[j];
				similarities[j] = similarities[j+1];
				similarities[j+1] = temp;
				temp = tempIndexArray[j];
				tempIndexArray[j] = tempIndexArray[j+1];
				tempIndexArray[j+1] = temp;

			} // end if
		}		//end for

	}	// end for

	// Display Person Similarities
	cout <<"\nFriends of " << questions[0] << questions[1]<< " with most similarities are:"
		 << endl;
	for (int i= 0; i< (numRec >= 10 ? 10: numRec); i++)
	{
		cout << Students[tempIndexArray[i]]->getFirstName() 
			<< " " << Students[tempIndexArray[i]]->getLastName()
			<< " with " << similarities[i] << " similarities" << endl;
	}


}
void LoadDatabase(ifstream& inFile)
{
	string fName, lName, maj, skul, count, gen, fHero, fSport, fFood;

	if (inFile.is_open())	// Read Data from file
	{
		while ( inFile >> fName)
		{
			inFile >> lName;
			inFile >> maj;
			inFile >> skul;
			inFile >> count;
			inFile >> gen;
			inFile >> fHero;
			//inFile >> fMus;
			//inFile >> fSport;
			inFile >> fSport;
			inFile >> fFood;
			// Create New Person
			Students[numRec] = new StudentData(fName, lName, maj, skul, count, gen, fHero, fSport, fFood);
			numRec++;
		}
		inFile.close();
	} // End if
	else cout <<"Unable to open File";
	displayRecord();
	
}

// Display User Menu
void displayMenu()
{
	cout << endl <<"********** Select Your Option ************ "<<endl;
	cout << "\t1.Find friend"<<endl;
	cout << "\t2.Update a person record"<<endl;
	cout << "\t3.Delete a person"<<endl;
	cout << "\t4.Exit"<<endl;
}

void displayRecord()
{
	cout << setw(10) << "FirstName" << setw(10) << "LastName" 
		 << setw(7) << "Major" << setw(4) << "EDU"
		 << setw(9) << "Country" << setw(7) << "Gender" 
		 << setw(10) << "SHero" //<< setw(8) << "Music" 
		 << setw(13) << "Sport" << setw(10) << "Food\n"; 
	cout <<"*******************************************************************************\n";
		 

	for (int i= 0; i<numRec; i++)
	{
		//int x;
		cout << setw(10) << Students[i]->getFirstName();// << "\t";
		cout << setw(10) << Students[i]->getLastName();// << "\t";
		cout << setw(5)  << Students[i]->getMajor();//	<< "\t";
		cout << setw(6)  << Students[i]->getSchool();// << "\t";
		cout << setw(9)  << Students[i]->getCountry();//	<< "\t";
		cout << setw(5)  << Students[i]->getGender();
		cout << setw(12) << Students[i]->getHero();//	<< "\t";
		//cout << setw(8) << Students[i]->getMusic();//	<< "\t";
		cout << setw(13) << Students[i]->getSport();// << "\t";
		//cout << setw(10) << Students[i]->getShow();//	<< "\t";
		cout << setw(9) << Students[i]->getFood();
		cout << endl;
				
	}

	

	
}
/*void updateRecord(fstream& output, string questions[9], string answers[9])
{
	string fName, lName, maj, skul, count, gen, fHero, fSport, fFood;
	cout << "\nUpdating Record" << endl;
	cout << "Enter First Name: ";
	cin >> fName;
	cout << "Enter Last Name: ";
	cin >>lName;

	int personNum = -1;
	// Check to see if Person Entered Match
	for (int i= 0; i< numRec; i++)
	{
		if(Students[i]->getFirstName() == fName && Students[i]->getLastName() == lName)
		{
			personNum = i;
		}
	}
	// If person Doesn't Exist
	if (personNum == -1)
	{
		cout <<"\nPerson can't be updated because he doesn't exist." << endl;
	}
	else
	{
		cout <<"Update answers for " << fName << " " << lName << endl;

		for (int i= 2; i< 7; i++)
		{
			cout << questions[i];
			cin >> answers[i];
		}
		Students[personNum]->setMajor(answers[2]);
		Students[personNum]->setSchool(answers[3]);
		Students[personNum]->setCountry(answers[4]);
		Students[personNum]->setGender(answers[5]);
		Students[personNum]->setHero(answers[6]);
		Students[personNum]->setSport(answers[7]);
		Students[personNum]->setFood(answers[8]);

		cout <<" Record of the Person Updated" << endl;
		cout << "\nAfter update, Reocrds are: " << endl;
		displayRecord();
	}
}*/
Last edited on
This is the error pop up

Error 1 error LNK2019: unresolved external symbol "void __cdecl LoadDatabase(class std::basic_fstream<char,struct std::char_traits<char> > &)" (?LoadDatabase@@YAXAAV?$basic_fstream@DU?$char_traits@D@std@@@std@@@Z) referenced in function _main E:\Finale_Finder\Finale_Finder\Finder.obj
Topic archived. No new replies allowed.