• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 248
  • Last Modified:

Release mode changes file writing behavior!!

im at a loss here, i have a program that allows you to input airport flight data manually or from data i get in excel file formats. i had an excel sheet with info on 80 something airports and all their terminals, the program automatically reads them all in and makes .flt files that contain all the data. when saved or created the data is all on one line. it first writes a structure of airport data then one struct for each flight. so im using .read and .write.
in debug mode all of this works fine, i switched it to release mode to give to my boss and all of a sudden no flights are loading into the listview. i looked at the flt file and now its the same size on the disk but i see alot more data, and its not on one line its all broken up.
if i replace the flt file with the old one that works switch to debug, save and open it works again. why would switching modes do something like this!?!? i never heard of that
0
PlanetCpp
Asked:
PlanetCpp
1 Solution
 
jkrCommented:
>>hy would switching modes do something like this!?!?

A debug build differs from a release build when it e.g. comes to initialize memory. If you have for example character arrays or dynamically allocated buffers, they will be initialized to zero and get padded with control structures to make it easier to detect buffer overwrites. If this is suddenly missing in a release vuild and you have one small error that e.g. relies on a preinitialized buffer for it's NULL termination, problems like that are likely to surface.
0
 
grg99Commented:
You're probably doing something like a strcat( Line, data ),  where you forgot to initilize Line to an empty string with strcpy( Line, "" );

0
 
itsmeandnobodyelseCommented:
>>> the program automatically reads them all in and makes .flt files

Actually, .flt extension doesn't seem to be a standard Excel file extension. Is it your own code that writes to the .flt file? If yes, you should post the code.

Why don't you use .csv files (comma separated values)? With these, you would get a new line for any new row in Excel, all values separated by semicolon or comma.

What platform and what compiler you are using?

Regards, Alex
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
PlanetCppAuthor Commented:
no flt is the file i create using manually entered data and data from excel files.
im trying the other suggestions, im zeroing the structs before i use them. so far its still not working in release mode
0
 
_corey_Commented:
You need to do more useful debugging *output* while in release mode then to find out where exactly the versions are deviating.

I'm unsure how you are writing to the file, but perhaps file pointers and locations.  Lines of data read-in vs how many are written out/etc.

More information on how you're accomplishing this might help.

corey
0
 
PlanetCppAuthor Commented:
clearing the flight struct helped before i saved data,, before i did it in the open function by accident when i said clearing it still didnt work. 7 years and i never ran into this problem? lol guess its never too late.
 thanks
0
 
jkrCommented:
>>7 years and i never ran into this problem? lol guess its never too late.

Check out http://www.codeproject.com/debug/survivereleasever.asp ("Surviving the Release Version")
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now