I'm taking a list of numbers that are strings and comparing them to a list of numbers that are strings in an array. When a number in the list matches a number in the array, "Match Found" is displayed. For the matching numbers nothing else should be displayed. For number 6, "Match Not Found" is displayed.
List: 12346
Array: 12345
Note:
while(not end of file)
{
for(i = 0; i < arraycount; i++)
{
if(strcmp(numberlist.numbers,array[i].numbers) == 0)
//Display "Match Found"
}
}
I'm not sure what to do after this point or if I'm even approaching this right. If I put an else statement that displays "Not Found" after the if statement then this is displayed for the "Match Found" numbers.
Example of what I do not want:
1 Match Found Not Found Not Found Not Found Not Found
2 Not Found Match Found Not Found Not Found Not Found
3 Not Found Not Found Match Found Not Found Not Found
4 Not Found Not Found Not Found Match Found Not Found
6 Not Found Not Found Not Found Not Found Not Found
Example of what I want:
1 Match Found
2 Match Found
3 Match Found
4 Match Found
6 Not Found
This is for a beginners class, so I have to keep the code at a beginners level.
Edit:
Solution
while(not end of file)
{
for(i = 0; i < arraycount; i++)
{
found = 0;
if(strcmp(numberlist.numbers,array[i].numbers) == 0)
found = 1;
//Display "Match Found"
}
if (found != 1)
//Display "Not Found"
}