I am to write a program that opens a file (input.txt) that contains unsigned values. The program has to ask the user for a couple of commands. The first command is "f <value>". This will mean that the user inputs "f" and then a inputs a value 0-3. The value inputted pretains to a certain nibble value. if user inputs "f" and a value, the program searches through the file for which numbers have that inputted value and in which nibble. The program then outputs which item it was and which nibble it was. for example, the file contains 271, 17767, 35243, 52719, 257.
user inputs "f 0"
program will output the following:
Match: Item 0, Nibble 3
Match: Item 4, Nibble 1
Match: Item 4, Nibble 3
My question is how do I get the program to check the items in the file to see which nibbles match the inputted value. So far, I have gotten the program to actually read the file for the items and just output them in 4 digit hexadecimal. I know I am to use a for loop for the "f <value>". I just don't know how to actually get the program to check and mask for the nibble value that is inputted and which items actually contain that value in which nibble. If anything is confusing in my explanation, please let me know. Thank you in advance for any help.