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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dev7060
    Recognized Expert Contributor
    • Mar 2017
    • 656

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

    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>>Trigonome try>> 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>>Trigonome try>> 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>>Polynomia ls>>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?
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    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:



    Comment

    Working...