HELP!!I need to know whether in c++ we can read values from a .txt file and use it to calculate something.
EXAMPLE:-
In the TEXT FILE-
FoodCode: f2,f3,g2
where anything of type 'f' is 50bucks and of type 'g' is 100bucks.
&
By using a C++ Program i want to calculate the overall cost of the order.
Like adding f2+f3+g2=50+50+100
and finally Output=200bucks;
The program should read only the 2nd line(coz thats where the food codes are entered)
Pls respond as soon as possible.
Thank You
That is how you get data from a file (replace variable with the name of a variable in your program and * with the name of a .txt file.)
You need to include the <fstream> library for it work.
About the calculations
Just declare a new variable and use