having issues with serial search

if i only enter 1 set of records i get a correct return but if i enter more than one set of record it only reconizes the last set. so when i search for student id the only one thats in the file that works correctly and displays the correct output is the last studentid entered rest dont work properly. basically its not starting at the first line of the file each search.



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
void loadarray() {
	fin.open("E:\\studentidarray.txt");
	
	string word;
	vector<string> myWords;
	while (fin >> word)
	{
		myWords.push_back(word);
		
	}
	fin.close();
	
}
void search_data()
{
	match = 'N';
    row = 0;
	maxsize = 8;

	cout << " enter a student id to be searched:    ";
	cin >> students;
									

	while (match == 'N' && row < maxsize)
	{
		if (students == studentid)
		{
			match = 'Y';
		}
		else
		{
			row = row + 1;
		}

		if (match == 'Y')
		{
			sucessful();
		}
		else
		{
			unsucessful();
		}
	}
Last edited on
anyone see what would make it not start at line one of file each search?
Last edited on
Your code doesn't make much sense to me.
You load the file into a vector but don't use to search.
Normally you should pass the vector to the search_data() function or are these two not related?.
Topic archived. No new replies allowed.