-
ifstream problem
I have written a program to write a file and save as txtfile. i have then written another to read said txt file. I can display this file no problem.
i now have to be able to read specific lines from this txt file so that i can create an order but i am really having no joy. do i need to copy the file into my existing program in order to take information from it?
the txt file is basically a menu with a list of itemno product and prices. i need to be able to create and order of say itemno 3, and a qty of 2 but the prodram needs to be able to read the file to see what itemno 3 is and how much it costs.
i have written the code for the no and qty but it is not reading the file forwhat it is and the cost. How do i go about doing that?
any hints would be great thanks
-
Unless you are writing fixed-length records (which is doubtful given your description) then you'll have to read the entire file into your program, or at least until you find the information you're looking for.
If there isn't too much data, I might read the whole thing in to data structures first and then just query the data structures. But that decision depends on a bunch of other factors.