My problem is: having a file like this
.....pinco pallino is tall 1.82
....tizio is tall 1.68
and so on I have to read a double number in input from the user and find it in the file when following "is tall" (with a tolerance of +/-0.01). Once I find "is tall myNumber" I have to output all the section that contains my recognition string that goes from "begin" to "end". I am now developing a code that, given the number, generate three numbers(the same, increased of 0.01 and decreased of 0.01) and render these in arrays of characters. My intention is to read every section starting with "begin" and stopping with "end" as a string array and using function find to focus on my recognition string using my three numbers (that now have become strings)
1)Can I use static_cast<string> on an array of carachters?
2)Is there a simpliest way, for exemple using the number as it is and using function fabs?
3) In case this is possible how can I retrieve the text from "begin" to "is tall x.xx"?
and so on I have to read a double number in input from the user and find it in the file when following "is tall" (with a tolerance of +/-0.01).
1 2 3 4 5 6 7 8 9 10 11
read in number of type double
read line of text of type sttring
search text for"is tall"if"is tall" in text
assume the folllowing word is number held as text
read that number into another number of type double
find the difference between the two numbers
if absolute value of difference <= 0.01
found = true