How would I error check this

I am having trouble trying to figure out how to error proof this code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
int addDays=0;
	int index =0;
	int position =-1;
	bool found =false;
	string value;
	cout << "Please enter the last name ";
	cin >> value;
	while(index< max && !found)//while loop to find by last name to change reveiw date
	{
		if(emps[index].lname == value)
		{
			found =true;
			position =index;
		}
		index++;
	
	}


I tried this
1
2
3
4
5
	while (index> max && !found )
	{
		cout << "\nDay must be between 1 and 31 - re-enter: ";
		cin >> value;
	}

and it didn't work, i have also tried if statments. This is a linear search and I am trying to check to make sure the users input can be found (I have done this) and then tell give the user an error message if not found and prompt the user for another input
Topic archived. No new replies allowed.