What is any easy way, if any, to save and load data in c++?
Compiler-Devcpp Os-Windows ME
What is any easy way, if any, to save and load data in c++?
Compiler-Devcpp Os-Windows ME
Save/read your object to/from files. Overload insertion (<<) and extraction (>>) operators for your object to make things easy.
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens
Do i use the fstrem.h header? And do i use a text file or what?
Yes, use an fstream object
Eg
Saving would be
fout << name << age;
Loading would be
fin >> name >> age;
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
ive been making a program to keep track of mountain dew ive sold in school
ive used text files to keep track and works very well when i save info but ive been trying to comprehend an easy way to read from my file all i can think of is reading numbers from the text file but wouldnt that have to be saved as a string?