Re: Steganography MFC program problem...
Asm is right that the 'i' variable is only in the scope of the for loop. In
fact, I'm surprised it will even compile (if it will compile). Another
trick is that you can turn off the new for scope "fix" in the project
properties, but I recommend you fix the problem instead as it's really a
better solution. Asm has provided that code and the fix is very simple.
Tom
<anantnigam03@rediffmail.com> wrote in message
news:1181385865.804716.135640@q75g2000hsh.googlegroups.com...
Hi all,
I am trying to understand this piece of code. It is generating few
errors..
Well i have commented the section where i get the exception about i is
not defined. Whereas i is defined. But it keeps on giving me this
error. If i define i of for loop ..still i get the same error. And
also i dont understand what this statement"
message_file.open("message.steg",ios::out|ios::binary);" is doing. I
know its to open the file ..But there is no file by this name
anywhere. So is it created itself to store the message that i type in
or wt....
Any help would be highly appreciated...
thanks
void encrypt_message::message_encryption()
{
int no_of_chars = 8;
//int i;
TCHAR c;
wofstream message_file;
wifstream message_encrypt_file;
message_file.open("message.steg",ios::out|ios::binary);
for(int i = 0; i<_tcslen(message);i++)
message_file.put(message[i]);
message_file.close();
get_key();
sub_key();
message_encrypt_file.open("message.steg", ios::in|ios::binary);
message_file.open("encrypted.steg", ios::out|ios::binary);
while(message_encrypt_file)
{
for(i=0; i<8; i++)
{
if(!message_encrypt_file)
{
message[i]='\0';
break;
}
else
{
message_encrypt_file.get(c);
message[i]=c;
}
}
message[i]='\0'; // EXCEPTION HERE THAT i is used without
defining.
convert_to_bits(message, message_in_bits);
sub_message();
_tcscpy_s(message_in_bits,encrypted_in_bits);
convert_from_bits();
for( i=0;i<no_of_chars;i++)
message_file.put(message[i]);
}
message_file.close();
message_encrypt_file.close();
message_encrypt_file.open("encrypted_message.steg", ios::in|
ios::binary);
i=0;
while(message_encrypt_file)
message_encrypt_file.open("encrypted_message.steg",ios::in|
ios::binary);
i = 0;
while(message_encrypt_file)
message_encrypt_file.get(message[i++]);
message[i]='\0';
message_encrypt_file.close();
}