Solved

Object that writes itself

Posted on 1998-06-02
3
171 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now