bug [incorrect incrementation of variable]
K so I was having fun writing a little steganographic application, but one of the member functions is giving me a hard time.
In the code below:
Code:
unsigned long count(char file[])
{
char c;
unsigned long size=0;
fstream test(file,ios::in||ios::binary);
while (!test.eof())
{
test.read(&c,1);
size++;
}
test.close();
return size;
}
size comes up with the value of 107, although I've used to different files to test it with [as it is called under main()]. Now if not anything else, the two files were very different in length, so even in the case of an overflow the two numbers should have been different I think. Any ideas at all? I've looked and looked at the code but I'm blanked out for ideas. Any help is infinitely appreaciated.
Thanx!