Solved

Object that writes itself

Posted on 1998-06-02
3
197 Views
Last Modified: 2010-04-01
I have an object that writes out about 950 bytes in total to a file.  When I compile a release version of the program the object starts to write random garbage to the file inbetween the values.  If I change one of the charater arrays in the object  from 450 to 300, it works again.   My question is, is there a limit to the number of bytes that can be written to a file using outfile.write( (char*)this, sizeof(*this)) in realease mode ???  Is there another way to write this object to the file?  It is a console appliation compiled under VC++ 5.0 SP3
0
Comment
Question by:delvin
  • 2
3 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 100 total points
ID: 1165148
No there is no limit to the number of bytes that can be written.   you've got a bug.  If you post the code I might be able to help you.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1165149
Note that in general this is not the best way to read and write objects (unless these objects obey certain restrictions.)  However, why don't you post your code before we worry about that.
0
 

Author Comment

by:delvin
ID: 1165150
I figured it out.  The object that was passing information to the one I was having problems with was not initializing the data correctly.  

Dooo! :)

Thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question