I have written a function for my code in which I have a .txt file with an array of 50 with only 11 numbers inserted. Therefore at the beginning of this function my num_records which is what i used to store the total amount of numbers in the file, will be 11. When a user enters a number I want this function to find the number or display an error if the number is not in the file. An example to test it would be that 5 is in the .txt file while 8 is not. Though this loop won't break.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
{
bool found = false;
while (!found || num_records != 0)
{
if (list[num_records] == target)
{
cout << target << endl;
found = true;
}
num_records--;
}
return found;
}