Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8062045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:32:11+00:00 2026-06-05T10:32:11+00:00

I’m working with c++ and I am writing a budget program (I’m aware many

  • 0

I’m working with c++ and I am writing a budget program (I’m aware many are available–it’s just a learning project).

I want to save what I call a book object that contains other objects such as ‘pages’. Pages also contain cashflows and entries. The issue is that there can be any amount of entries or cashflows.

I have found a lot of information on saving data to text files but that is not what I want to do.

I have tried looking into using the boost library as I’ve been told serialization might be the solution to this problem. I’m not entirely sure which functions is boost are going to help or even what the proper ways are to use boost.

Most examples of binary files that I have seen are with objects that have fixed size members. For example, a point might contain an x value and a y value that are both doubles. This will always be the case so it is simple to just use sizeOf(Point).

So, I’m either looking for direct answers to this question or useful links to information on how to solve my problem. But please make sure you links are specific to the question.

I’ve also posted the same question on cplusplus

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T10:32:13+00:00Added an answer on June 5, 2026 at 10:32 am

    In general, there are two methods to store variable length records:

    1. Store size integer first, followed by the data.
    2. Store the data, append a sentinel character (or value) at the end.

    C-style strings use the 2nd option.
    For option one, the number contains the size of the data.

    Optional Fields

    If your considering relational database design for optional fields, you would have one table with the known or fixed records and another table containing an option field with the record ID.

    A simpler route may be to go to something similar to XML: field labels.
    Split your object into two sections: static fields and optional fields.
    The static field section would be followed by an optional field section. The optional field section would contain the field name, followed by the field data. Read in the field name then the value.

    I suggest you review your design to see if optional fields can be eliminated. Also, for complex fields, have them read in their own data.

    Storing Binary Data

    If the data is shared between platforms, consider using ASCII or textual representation.

    Read up upon Endianess and also bit sizes. For example one platform could store its binary representation least significant byte first and use 32 bits (4 bytes). The receiving platform, 64-bit, most significant byte first, would have problems reading the data directly and would need to convert; thus losing any benefit from binary storage.

    Similarly, floating point doesn’t fare well in binary either. There is also the loss of precision when converting between floating point formats.

    When using optional fields in binary, one would use a sentinel byte or number for the field ID rather than a textual name.

    Also, data in textual format is much easier to debug than data in binary format.

    Consider using a Database

    See At what point is it worth using a database?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
i want to parse a xhtml file and display in UITableView. what is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.