429,066 Members | 1,841 Online
Need help? Post your question and get tips & solutions from a community of 429,066 IT Pros & Developers. It's quick & easy.

# How to save the the details of performed operations to a file?

 P: 90 Is there any way I can save the details of performed operations to a binary file and retrieve them when required? Let's say the program of a calculator. An option can be provided where a user can save all the performed tasks' history to a binary file and can retrive that data later on. For example: (Output screen) -------------------------------------------------------------------------- Menu>>Trigonometry>> Roots calculation Enter equation: cos(2x)-2sin(x)cos(x) Calculating. . . Result: x=(π/8)+k(π/2) , k∈Z Press: 's' to save the record, 'r' to return to the main menu ------------------------------------------------------------------------- *when the user presses 's', the record should be saved in the binary/text file as*: Date: dd/mm/yyyy Time: [hh]:[mm] Category: Menu>>Trigonometry>> Roots calculation Input(s): cos(2x) -2sin(x)cos(x) Result(s): x=(π/8)+k(π/2) , k∈Z *similarly for others as* Date: dd/mm/yyyy Time: [hh]:[mm] Category: Menu>>Polynomials>>Addition Input(s): [7x^2]+[4x^5] , [3x^2]+[6x^9] Result(s): [10x^2]+ [4x^5]+ [6x^9] ----------------------------------------------------------------------- And hence, the user can request that data later on (from the main menu) accordingly like if he wants to view the saved records of a particular date.. I feel like this can be implemented using class objects dealing with files and time libraries. Is this feasible? May 31 '18 #1

You will need to read up on file handling in C++. Most likely you will use a stream object, like ofstream.

Be sure you read the data in your file in the same order that it was written.

This will get you started:

https://bytes.com/topic/c/insights/9...te-text-file-c