C++ - weird behaviour

addle_brains

New Member
There's no programming forum, so I'll post here. I'm currently looking into steganography and I wrote a small program in C++, just to see if I could. The program reads in a text file and a BMP file, converts the decimal values of the characters to binary arrays and applies the appropriate operations on them to hide the text data in the bitmap. This part works fine (as far as I can tell with the use of debugging text.) My problem occurs when trying to save the new BMP data to file.

The program makes use of a class called Steg which provides all the necessary functions to do the program. There is a public member function called Run() which handles the whole process. Currently, Run looks like this

void Run() {
std::cout << "Processing...";
FixBMP(); //hides the text data in the BMP
std::cout << "Done!" << std::endl;

std::cout << "Saving...";
SaveToFile(); //saves the new BMP to file.
std::cout << "Done!";
}

When running the program, I get this output
---------------------------
Processing...Done!
---------------------------

Then it stops. No error message or stack overflow or nothing. It just stops there. Now, if I go to the SaveToFile() function and remove the fstream operations and simply fill it with trivial arithmetic or something, the program runs properly. I cannot figure out why the function won't work if I try to open a filestream for output.

Sorry for all the detail, but I want to make sure I cover everything. Any Ideas? Anyone come across this before? I'm using the MinGW compiler with msys.
 
well, I am not so much advanced in C++ but I could may help: can you have the permission to write to the file, you know that you must enable the permission to write to files and after that close it
 
I'm not an expert in c++, and I'm not even sure if that's .net or not. However, in visual basic you have to use some kind of input output file stream and tell it where to save it in a save file dialog box.

in your situation, once again i'm not quite sure, did you ask it where to save it?
 
Back
Top