I want to write a program that take a 6 digit number from 1 text file and match it with another 6 digit number in another file.
if matched display it on the screen.
help me please.....
I'm not quite sure that you fully understand your code's control flow.
You get the first number from "bond.txt" then you go through the whole file "lists.txt" in the nested while loop and you reach end of file, note that you are still in first iteration of the outer while loop, and on the second iteration of the outer while loop the nested while loop will no longer be executed because you already reached the end of file in "lists.txt".
Load the content of each file in a std::vector<int>. You should have a for loop to traverse the first container and a nested for loop to traverse the second container. If one file is longer than the other then the second for loop should traverse the longer std::vector<int>.
Going to the beginning of the file every time isn't efficient because reading from the disk is exponentially slower than reading from main memory.