list line

does anyone knows how to tak out a single number from a list of a file and then process it for example if you call a data file that has this lis of numbers : 1 2 3 4 how can i take just take the 1 to process in a math problem and then take the 2 a do the same ? please help
from a text file?
1
2
3
4
5
6
7
8
9
ifstream file("yourfile.txt");

// assuming file contains "1 2 3 4"

int a, b, c;

file >> a;  // a == 1
file >> b;  // b == 2
file >> c;  // c == 3 
thank you. so the i can use the a as the valiu to put it in a proble for example
z= 2 + a ?
z=3?
thank you so much
yup
Topic archived. No new replies allowed.