I see a monstrous fragment in attached code:
string FileName;
char __TEMP__[256];
cin.getline(__TEMP__, 256);
FileName = __TEMP__;
delete [] __TEMP__;
Don't continue. You try to deallocate (free) stack (automatic) array. Of course, now program stack is corrupted, program behaviour is undefined and so on...
Apropos, see quote from C++ Standard:
17.4.3.1.2 Global names
Certain sets of names and function signatures are always reserved to the implementation:
— Each name that contains a double underscore _ _ or begins with an underscore followed by an uppercase letter (2.11) is reserved to the implementation for any use.
— Each name that begins with an underscore is reserved to the implementation for use as a name in the global namespace.
So it's not recommended to assign __TEMP__ to your local variables: it's not a good practice.
ArkM
Postaholic
2,001 posts since Jul 2008
Reputation Points: 1,234
Solved Threads: 348
You have discounted newline conversions.
On Windows, the newline character represents the ASCII sequence CR LF.
When your program reads it, it gets '\n'. The newline is encrypted thus and so the output file is shorter than the input file, because the encrypted data doesn't have as many '\n's (if any) as the source.
You'll also notice that when it says File Length: that it gives the shorter size.
When decrypting, you get back that '\n', which is written to file as CR LF, thus increasing the output file size (back to the original size).
Some observations:
is evil.
Use functions.
Hope this helps.
Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
Hello :
Nice job, which algorithm you used to do this??
thanks
aminit
Junior Poster in Training
78 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0