Im a new beginner to C++ and i have a question.
I have a .txt document with many different values.
I would like to return a value from the .txt file depending on what value i give in.

I want to pass how many lines in the .txt file.
eg. text file contains:

5 (lines in .txt file)

and my test values are:

If I pass 0.02 function should return 100. 0.03 should return 1000.

Can anyone give me a good example of this?

Best regards

why are you passing fractional values instead of whole numbers. When you pass 0.02 does that mean to get the line that contains 2 zeros, e.g. 100? Then why not just pass 2 instead of 0.02?

Hi, Thank you for your answer.

The reason why im passing fractional values is because I want to pass ullage to the function and return volume from a .txt file. The txt file is actually a volume table.

Maybe I will need to pass step value to the function as well?

Any example will be appreciated.

Best regards

Just multiply the parameter by 100 to get a whole integer, then return the line in the file which has that many digits. Is the file already sorted in numeric value in descending order? If not, then you will probably have to read the entire file and pick out the lines that you want.

Hi Ancient Dragon,

Thank you for your answer.

The file is already sorted with the highest number on top and lowest number in bottom according to ullage.

I will try to program it in VS.
Thank you.