I/O stream and data files

Hi im trying to input an integer from a text file that contains a word first then the integer im trying to save into a variable. for example, if i have a text file that looks like the following,

min 2
max 17
mean 5
sigma 10

i only want the 5, 10, and 2 saved into a variable. So in my code i have

inFile >> min;
inFile >> max;
inFile >> mean;
inFile >> sigma;

so if i use the command
cout << min << max << mean << sigma;
i want it to display 2 17 5 10


thank you
i only want the 5, 10, and 2 saved into a variable.


It will be far easier for you to read in the words as well, and just not use them.

1
2
3
4
5
6
7
8
9
10
inFile >> word;
inFile >> min;
inFile >> word;
inFile >> max;
inFile >> word;
inFile >> mean;
inFile >> word;
inFile >> sigma;

cout << min << " " << max<< " " << mean<< " " << sigma;
thank you Moschops that really helped.
Topic archived. No new replies allowed.