find a number in a file with C++

Hello,
I would like to know if I have a text file contains two columns and too many rows, how to find a number under the second column by giving the program the value
beside it in the first column ?
I mean simply if:

x y
1 6
2 7
3 8
4 9
5 10
how to give the program x=4 to print " y=9"?

Thanks in advance.

Make a loop that reads in numbers from file and checks the values.

1
2
3
// inside loop
cin >> x_value >> y_value;
if (x_value == search_value) cout << "y=" << y_value << endl;

Topic archived. No new replies allowed.