• 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
1 Solution
>>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.
You're probably doing something like a strcat( Line, data ),  where you forgot to initilize Line to an empty string with strcpy( Line, "" );

>>> 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
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
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.

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.
>>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")

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