Reading bmp file for steganography

Posted by Shantanu Gupta on Stack Overflow See other posts from Stack Overflow or by Shantanu Gupta
Published on 2010-03-21T20:14:06Z Indexed on 2010/03/21 20:31 UTC
Read the original article Hit count: 572

Filed under:
|

I am trying to read a bmp file in C++(Turbo). But i m not able to print binary stream.

I want to encode txt file into it and decrypt it. How can i do this. I read that bmp file header is of 54 byte. But how and where should i append txt file in bmp file. ?

I know only Turbo C++, so it would be helpfull for me if u provide solution or suggestion related to topic for the same.

int main()
{
ifstream fr; //reads
ofstream fw; // wrrites to file
char c;
int random;
clrscr();
char file[2][100]={"s.bmp","s.txt"};

fr.open(file[0],ios::binary);//file name, mode of open, here input mode i.e. read only
if(!fr)
    cout<<"File can not be opened.";
fw.open(file[1],ios::app);//file will be appended
if(!fw)
    cout<<"File can not be opened";
while(!fr)
    cout<<fr.get(); // error should be here. but not able to find out what error is it

fr.close();
fw.close();
getch();
}

This code is running fine when i pass txt file in binary mode

© Stack Overflow or respective owner

Related posts about c++

Related posts about turboc++