Help with displaying error message

Hello, I am working on a program for a historical society to allow them to log artifacts in their museum. I have implemented a search function so they can see all the items under one category. Everything works well except getting the error to display correctly. The categories are out of order, so some data from one category will display, there will be errors from data from the other categories, and then the rest of the correct data will display. I will post the code below. Any help or guidance would be greatly appreciated.

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
void Record::searchRecsCat(string uCat)
{
	//create HANDLE object
	HANDLE hConsole;
	hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

	//clear vectors
	fileNumbers.clear();
	categories.clear();
	tagStrings.clear();

	//populate vectors
	populateVectors();

	//assign value to private data member
	userCat = uCat;

	//loop through folder names
	for (unsigned long i = 0; i < categories.size(); i++)
	{
		//determine if match is found
		if (userCat == categories[i])
		{
			//display data
			cout << "Photo " << i + 1 << " data:" << endl;
			cout << "----------------" << endl;
			cout << "File number: " << fileNumbers[i] << endl;
			cout << "Category: " << categories[i] << endl;
			cout << "Tags: " << tagStrings[i] << endl;

			//skip line
			cout << endl;
		}
                else
                {
                        //error message here
                } //end if
	} //end for
} //end of searchRecsFolder method 
Last edited on
Have you considered to use exceptions?
http://www.cplusplus.com/doc/tutorial/exceptions/

Last edited on
Topic archived. No new replies allowed.