How to use information stored in file as variables in program? and how to randomly access some information in file in c++ ? | Sololearn: Learn to code for FREE!

+1

How to use information stored in file as variables in program? and how to randomly access some information in file in c++ ?

I've stored the date of costumer's arrival and when will he left in file ..now i want to calculate his bill using these dates ..how can I?

5/18/2018 10:43:30 AM

Maleeha Khalid

7 Answers

New Answer

+5

There are Sololearn C++ lessons on file manipulation.

+2

Go through these lessons: https://www.sololearn.com/learn/CPlusPlus/1920/?ref=app The getline function reads the file line by line and can be used to return a string of a line in the file to either stdout, a variable, a file, etc.

+2

Maleeha What more do you need?

+2

Maleeha Basically, you will have to loop through all lines in the file and save them to some form of data container that you can then access a line by an index to the container. Or, you can loop through all lines in the file until a desired number of lines is reached and then store that specific line.

0

Maxwell Anderson I've searched the whole course on file handling but couldn't find what I'm looking for..can you share a link?

0

this is basic..i've learnt it but my problem is still not resolved i.e how to access data in file ..Maxwell Anderson

0

I'm saving data of guests in file and after checkout their data has to be removed and file is to be updated ..if the data of 2 guest is from line 7 to line 10 ,how will I access it without having to read file from the start and how will it end before end of file ? Maxwell Anderson