I am probably doing something either terribly wrong or it's just something that requires a simple fix. I know I need to find at least 4 employees that don't match the employees in the class one array. But I get absolutely no output.

int ClassOne::binSearch(int employee)
{
	int first, last, mid, found;
	first = 0;
	last = empCount - 1;
	found = 0;

	while(first <= last && found == 0)
	{
		mid = (first + last) / 2;
		if(ids[mid] == employee)
			found = 1;
		else if(eids[mid] < employee)
			first = mid + 1;
		else if(ids[mid] > employee)
			last = mid - 1;
	}
	if(found == 0)
		mid = -1;
	return mid;
}
void ClassTwo::pay()
{
	int employee, location;
	classOneArray.loadArrays();
	classOneArray.bubbleSort();
	for(int i = 0; i < idCount; ++i)
	{
		employee = payIds[i];
		while(i < idCount)
		{
			location = classOneArray.binSearch(employee);
			if(location >= 0)
			{
				for(int i = 0; i < idCount; ++i)
				{
					goodIds[i] = employee;
				}
			}
			else
			{
				for(int i = 0; i < idCount; ++i)
				{
					cout << "Employee " << employee << " not found!" << endl;
					badIds[i] = employee;
				}
			}
		}
	}
}

Okay figured out what I did wrong. I had to take out the while loop inside the for loop. Now I just have to find out if I loaded the 2 arrays in the for loop correctly so they can print.

Edit: Okay those 2 arrays, goodIds and badIds, aren't loading correctly. They seem to be holding as many IDs as are read in from the file but every value is the last value read in.. ... like a whole line of 44444 44444 44444 44444...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.