how to create open, close, save, save as and exit functions in a c++ project?
This is my first project for university and I need to create a program which lets the user to create game characters by storing their info like name, age, strength, etc.. into a file.
The user needs to manually open a file by naming the directory in the terminal (e.g.
> open c:\\foldername\\filename.txt), call the functions they want and then have the choice to either close the file without saving it
> close , save it
> save or save it under another name/directory
> saveas c:\\newfoldername\\newfilename.txt
My problem is I don't exactly understand how to do it, is there a library where these functions are already included or do I need to write them by myself? And if I need to write them, how do I open a file where the contents of the file are loaded in the memory and after closing the file, they're still kept in memory without being saved unless the user explicitly says they want to be saved? Any kind of help is welcome, thank you in advance.
You can either use std::ifstream (preferred c++ way) which has
closemember functions or the functions
fclosewhich come from c.