Data Saving and Loading

This is a discussion on Data Saving and Loading within the C++ Programming forums, part of the General Programming Boards category; What is any easy way, if any, to save and load data in c++? Compiler-Devcpp Os-Windows ME...

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    12

    Data Saving and Loading

    What is any easy way, if any, to save and load data in c++?
    Compiler-Devcpp Os-Windows ME

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,801
    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

  3. #3
    Registered User
    Join Date
    Oct 2004
    Posts
    12

    reply

    Do i use the fstrem.h header? And do i use a text file or what?

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,541
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Oct 2004
    Posts
    12

    reply

    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?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. loading muliable table from a single file
    By linoukus in forum C++ Programming
    Replies: 12
    Last Post: 06-19-2008, 12:51 PM
  2. Saving and Loading Files
    By renanmzmendes in forum C++ Programming
    Replies: 6
    Last Post: 03-15-2008, 08:46 AM
  3. Major Problems with GetSaveFileName() and GetOpenFileName()
    By CodeHacker in forum Windows Programming
    Replies: 8
    Last Post: 07-12-2004, 11:05 AM
  4. Saving and Loading Linked Lists With File i/o
    By Red Army in forum C++ Programming
    Replies: 8
    Last Post: 05-15-2002, 03:19 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21