waffleShirt
waffleShirt

Reputation: 413

Why is C++ fwrite() producing larger output in release?

I recently wrote an implementation of the Canonical Huffman compression algorithm. I have a 500kb test file that can be compressed to about 250kb when running the debug and release builds from within Visual Studio 2008. However when I run the release build straight from the executeable the test file only compresses to about 330kb.

I am assuming that something is going wrong when the file is written using fwrite(). I have tested the program and confirmed that uncompressing the files always produces the correct uncompressed file.

Does anyone know why this could possibly be? How could the same executeable file be producing different sized outputs based on where it is launched from?

Upvotes: 0

Views: 401

Answers (3)

Alex Budovski
Alex Budovski

Reputation: 18456

Try running it through App Verifier and see what it finds.

Upvotes: 0

Stephen Nutt
Stephen Nutt

Reputation: 3306

Check out the the /RTCu compiler option to help detect use of uninitialized variables.

Upvotes: 2

Justicle
Justicle

Reputation: 15183

Sounds like an uninitialized value somewhere. See also: Program crashes when run outside IDE

Running in IDE will initialize values to global defaults, running outside IDE doesn't, so any uninit'd variables will have different values.

Upvotes: 3

Related Questions